NSString*hexColor = @"FFFFFF";
if([hexColor hasPrefix:@"#"])
{
hexColor = [hexColor substringFromIndex:1];
}
NSScanner*scanner = [NSScanner scannerWithString:hexColor];
unsigned hexNum;
int r =0;
int g =0;
int b =0;
if([scanner scanHexInt:&hexNum])
{
r = (hexNum >>16) &0xFF;
g = (hexNum >>8) &0xFF;
b = (hexNum) &0xFF;
}
网友评论