将 HSV 颜色值转换为 UIColor 对象的 Swift 扩展。
HSV 表示色调、饱和度和亮度,也常称为 HSB(B 代表亮度)。
公式来自 维基百科。
platform :ios, '8.0'
use_frameworks!
pod 'ColorWithHSV', '~> 0.0'
然后,运行以下命令:
$ pod install
将 /ColorWithHSV-iOS
文件夹拖动到项目中。这样就完成了。
let black: UIColor = UIColor.colorWithHSV(hue: 0.0, saturation: 0.0, value: 0.0)
let white: UIColor = UIColor.colorWithHSV(hue: 0.0, saturation: 0.0, value: 1.0)
let red: UIColor = UIColor.colorWithHSV(hue: 0.0, saturation: 1.0, value: 1.0)
let green: UIColor = UIColor.colorWithHSV(hue: 120.0, saturation: 1.0, value: 1.0)
let blue: UIColor = UIColor.colorWithHSV(hue: 240.0, saturation: 1.0, value: 1.0)
#import "ColorWithHSV-Swift.h"
...
UIColor *black = [UIColor hsv_colorWithHue:0.0 saturation:0.0 value:0.0];
UIColor *white = [UIColor hsv_colorWithHue:0.0 saturation:0.0 value:1.0];
UIColor *red = [UIColor hsv_colorWithHue:0.0 saturation:1.0 value:1.0];
UIColor *green = [UIColor hsv_colorWithHue:120.0 saturation:1.0 value:1.0];
UIColor *blue = [UIColor hsv_colorWithHue:240.0 saturation:1.0 value:1.0];
ColorWithHSV-iOS 在 MIT 许可证下发布。请参阅名为 LICENSE 的文件。
$ git tag -a 1.0.0 -m 'Version 1.0.0'
$ git push --tags
Gabriel Massana
如果您遇到与 ColorWithHSV-iOS 相关的具体问题,或者有功能请求,或者想分享评论,请在以下位置创建新问题: 这里。