文章标题

/**
将16进制的颜色值变成UIColor @”FFFF00”
*/
+(UIColor ) colorFromHexRGB:(NSString )inColorString {
UIColor *result = nil;
unsigned int colorCode = 0;
unsigned char redByte, greenByte, blueByte;

if (nil != inColorString)
{
    NSScanner *scanner = [NSScanner scannerWithString:inColorString];
    (void) [scanner scanHexInt:&colorCode]; // ignore error
}
redByte = (unsigned char) (colorCode >> 16);
greenByte = (unsigned char) (colorCode >> 8);
blueByte = (unsigned char) (colorCode); // masks off high bits
result = [UIColor
          colorWithRed: (float)redByte / 0xff
          green: (float)greenByte/ 0xff
          blue: (float)blueByte / 0xff
          alpha:1.0];
return result;

}

阅读更多
个人分类: iOS
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭