1. 程式人生 > >色值的封裝方法以及RGB和RGBA的區別

色值的封裝方法以及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]