类似于为 iOS 编写的 Android Palette。使用 Swift 编写并兼容 Objective-C,从任何视图(任何继承自 UIView 的内容)获取与另一个视图特定点处对比的颜色(黑色或白色)。
let palette = Palette(background:self.view, view:self.label)
self.label.textColor = palette.getContrastingColor()
或
self.label.textColor = Palette.getContrastingColor(self.view, forView: self.label)
Palette * palette = [[Palette alloc] initWithBackground:self.view forView:label];
label.textColor = [palette getContrastingColor];
或
label.textColor = [Palette getContrastingColor:self.view forView:label];