OC代码
#define UIColorFromRGB(rgbValue,alphaValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
alpha:alphaValue]
swift代码
func UIColorFromRGB(_ rgbValue:Int,_ alphaValue:CGFloat) -> UIColor {
return UIColor(red: CGFloat(((Float)((rgbValue & 0xFF0000) >> 16))/255.0) , green: CGFloat(((Float)((rgbValue & 0xFF00) >> 8))/255.0), blue: CGFloat(((Float)(rgbValue & 0xFF))/255.0), alpha: alphaValue)
}
//欢迎加入:洛阳iOS开发交流(570890454)
网友评论