Swift 扩展,用于将 HSL 颜色值转换为 UIColor 对象。
HSL 代表色调、饱和度和亮度,也常被称为 HLS。
公式来自 维基百科。
platform :ios, '8.0'
use_frameworks!
pod 'ColorWithHSL', '~> 0.0'
然后,运行以下命令
$ pod install
将 /ColorWithHSL-iOS
文件夹拖入您的项目中。就完成了。
let black: UIColor = UIColor.colorWithHSL(hue: 0.0, saturation: 0.0, lightness: 0.0)
let white: UIColor = UIColor.colorWithHSL(hue: 0.0, saturation: 0.0, lightness: 1.0)
let red: UIColor = UIColor.colorWithHSL(hue: 0.0, saturation: 1.0, lightness: 0.5)
let green: UIColor = UIColor.colorWithHSL(hue: 120.0, saturation: 1.0, lightness: 0.5)
let blue: UIColor = UIColor.colorWithHSL(hue: 240.0, saturation: 1.0, lightness: 0.5)
#import "ColorWithHSL-Swift.h"
...
UIColor *black = [UIColor hsl_colorWithHue:0.0 saturation:0.0 lightness:0.0];
UIColor *white = [UIColor hsl_colorWithHue:0.0 saturation:0.0 lightness:1.0];
UIColor *red = [UIColor hsl_colorWithHue:0.0 saturation:1.0 lightness:0.5];
UIColor *green = [UIColor hsl_colorWithHue:120.0 saturation:1.0 lightness:0.5];
UIColor *blue = [UIColor hsl_colorWithHue:240.0 saturation:1.0 lightness:0.5];
ColorWithHSL-iOS 采用 MIT 许可发布。请参阅名为 LICENSE 的文件。
$ git tag -a 1.0.0 -m 'Version 1.0.0'
$ git push --tags
Gabriel Massana
如果您遇到特定于 ColorWithHSL-iOS 的问题、有功能请求或想要发表评论,请在此处 打开新问题。