色值的封装方法以及RGB和RGBA的区别

// 取色值相关的方法
#define RGB(r,g,b)       [UIColor colorWithRed:(r)/255.f \green:(g)/255.f \blue:(b)/255.f \alpha:1.f]

#define RGBA(r,g,b,a)       [UIColor colorWithRed:(r)/255.f \green:(g)/255.f \blue:(b)/255.f \alpha:(a)]

//六位十六进制 色值
#define RGB_OF(rgbValue)     [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
 blue:((float)(rgbValue & 0xFF))/255.0 \alpha:1.0]

//八位十六进制色值
#define RGBA_OF(rgbValue)   [UIColor colorWithRed:((float)(((rgbValue) & 0xFF000000) >> 24))/255.0 \
 green:((float)(((rgbValue) & 0x00FF0000) >> 16))/255.0 \blue:((float)(rgbValue & 0x0000FF00) >> 8)/255.0 \alpha:((float)(rgbValue & 0x000000FF))/255.0]

猜你喜欢

转载自blog.csdn.net/sun_cui_hua/article/details/79717240
今日推荐