ImColorAdjustmenter 是一个可以玩转颜色数值的库。
要运行示例项目,首先克隆仓库,然后从 Example 目录运行 pod install
。
ImColorAdjustmenter 通过 CocoaPods 提供。要安装它,请简单地将以下行添加到您的 Podfile 中
pod "ImColorAdjustmenter"
let color = UIColor(hex: 0xB7EAE7)
let adjustmentColor = color.colorWithHBSComponent(hue: hueValue, brightness: brightnessValue, saturation: saturationValue)
adjustmentColorView.backgroundColor = adjustmentColor
let adjustmentColor = color.colorWithHBSComponent(hue: hueValue, brightness: brightnessValue, saturation: saturationValue)
adjustmentColorView.backgroundColor = adjustmentColor
if let hbs = adjustmentColor?.colorHBS() {
print("Hue = \(hbs.hue)")
print("Bridhtness = \(hbs.brightness)")
print("Saturation = \(hbs.saturation)")
}
let adjustmentColor = color.colorWithRGBComponent(r: rValue, g: gValue, b: bValue)
targetView.backgroundColor = adjustmentColor
if let rbg = adjustmentColor?.colorRGB() {
print("Red = \(rbg.r)")
print("Green = \(rbg.g)")
print("Blue = \(rbg.b)")
}
let colors: [CGColor] = [UIColor.whiteColor().CGColor, UIColor.redColor().CGColor]
let locations: [CGFloat] = [0.0, 1.0]
targetView.layerVerticallyGradient(colors: colors, locations: locations)
public convenience init(hex: Int, alpha: CGFloat = 1)
public func colorWithHBSComponent(hue hue: CGFloat, brightness: CGFloat, saturation: CGFloat) -> UIColor?
public func colorHBS() -> ImColorAdjustmenter.HBSProperties?
public func colorWithRGBComponent(r r: CGFloat, g: CGFloat, b: CGFloat) -> UIColor?
public func colorRGB() -> ImColorAdjustmenter.RGBProperties?
public func layerVerticallyGradient(colors colors: [AnyObject], locations: [CGFloat])
public struct HBSProperties {
public var hue: CGFloat = 0
public var brightness: CGFloat = 0
public var saturation: CGFloat = 0
public var alpha: CGFloat = 1
}
public struct RGBProperties {
public var r: CGFloat = 0
public var g: CGFloat = 0
public var b: CGFloat = 0
public var alpha: CGFloat = 1
}
ikemai
ImColorAdjustmenter 基于 MIT 许可证可用。有关更多信息,请参阅 LICENSE 文件。