码迷,mamicode.com
首页 > 其他好文 > 详细

16进制颜色值变幻UIColer

时间:2015-04-24 14:19:16      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:16进制颜色值变幻uicoler

+ (UIColor *) colorFromHexRGB:(NSString *) colorString

{

    UIColor *result = nil;

    unsigned int colorCode = 0;

    unsigned char redByte, greenByte, blueByte;

    

    if (nil != colorString)

    {

        NSScanner *scanner = [NSScanner scannerWithString:colorString];

        (void) [scanner scanHexInt:&colorCode]; 

    }

    redByte = (unsigned char) (colorCode >> 16);

    greenByte = (unsigned char) (colorCode >> 8);

    blueByte = (unsigned char) (colorCode); 

    result = [UIColor

              colorWithRed: (float)redByte / 0xff

              green: (float)greenByte/ 0xff

              blue: (float)blueByte / 0xff

              alpha:1.0];

    return result;

}


16进制颜色值变幻UIColer

标签:16进制颜色值变幻uicoler

原文地址:http://blog.csdn.net/heyachaodeios/article/details/45245771

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!