將十六進制色值轉成RGB

#import "UIColor+Extension.h"

@implementation UIColor (Extension)

+(instancetype)lz_colorWithHex:(u_int32_t)hex
{
    int red;
    int green;
    int blue;
    //AAECDD
    red=(hex & 0xFF000000) >> 16;
    green=(hex & 0x00FF00) >> 8;
    blue=hex & 0x0000FF;
    return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:1.0];
}

@end
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章