extension LECommon{
//rbg转UIColor(16进制)
class func RGB16(rgbValue:Int) -> UIColor {
return UIColor.init(colorLiteralRed:((Float)((rgbValue & 0xFF0000) >> 16))/255.0, green: ((Float)((rgbValue & 0xFF00) >> 8))/255.0, blue: ((Float)(rgbValue & 0xFF))/255.0 , alpha: 1.0)
}
//rbg转UIColor(16进制)带透明度
class func RGBA16(rgbaValue:Int) -> UIColor {
return UIColor.init(colorLiteralRed:((Float)((rgbaValue & 0xFF0000) >> 16))/255.0, green: ((Float)((rgbaValue & 0xFF00) >> 8))/255.0, blue: ((Float)(rgbaValue & 0xFF))/255.0 , alpha: ((Float)((rgbaValue & 0xFF000000) >> 24))/255.0)
}
class func RGBColor(r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) -> UIColor {
return UIColor.init(red: (r/255.0), green: (g/255.0), blue: (b/255.0), alpha: a)
}
}
参考文章:
http://www.cnblogs.com/PLA-Artillery/p/5809414.html
http://21lovetong.blog.51cto.com/9944813/1615797
http://www.jianshu.com/p/345fa430e44e
网友评论