Color2UiColor
示例
要运行示例项目,请克隆仓库,并使用 cd color2UiColor
命令进入目录,然后运行 pod install
需求
- iOS8
安装
Color2UiColor 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'Color2UiColor'
用法
在文件顶部导入 Color2UiColor
import Color2UiColor
初始化一个 Color2UiColor 对象
let c2uic = Color2UiColor()
Color2UiColor 提供了两个方法的包装
hexToUIColor(hex: String)
rgbToUIColor(r: Int, g: Int, b: Int)
您可以使用它们如下所示
button.tintColor = c2uic.hexToUIColor(hex: "#b10034")
button.tintColor = c2uic.rgbToUIColor(r: 123, g: 456, b: 789)
如果您需要设置透明度,只需在参数列表末尾添加一个alpha值。
hexToUIColor(hex: String, alpha: CGFloat)
rgbToUIColor(r: Int, g: Int, b: Int, alpha: CGFloat)
带有alpha值的示例方法调用
button.tintColor = c2uic.hexToUIColor(hex: "#b10034", alpha: 0.4)
button.tintColor = c2uic.rgbToUIColor(r: 123, g: 456, b: 789, alpha: 0.75)
作者
姓名: Maurice Gerhardt
Twitter: @mrcgrhrdt
许可证
Color2UiColor 遵循MIT许可证。有关更多信息,请参阅LICENSE文件。