取色值相关宏

iOS中,常用的获取RGB颜色值和十六进制颜色值转换方法的宏定义。
#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 RGBOF(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]

    #define RGBAOF(v, a)        [UIColor colorWithRed:((float)(((v) & 0xFF0000) >> 16))/255.0 \
                                                green:((float)(((v) & 0x00FF00) >> 8))/255.0 \
                                                 blue:((float)(v & 0x0000FF))/255.0 \
                                                alpha:a]

你可能感兴趣的:(取色值相关宏)