如果我有十六进制格式的颜色......如何在CGContextSetRGBFillColor(context, .?.)
中使用十六进制颜色?
这是唯一的方法吗?
NSString *color = @"0xe3f3fbff";
unsigned r,g,b,a;
[[NSScanner scannerWithString:[color substringWithRange:NSMakeRange(2,2)]] scanHexInt:&r];
[[NSScanner scannerWithString:[color substringWithRange:NSMakeRange(4,2)]] scanHexInt:&g];
[[NSScanner scannerWithString:[color substringWithRange:NSMakeRange(6,2)]] scanHexInt:&b];
[[NSScanner scannerWithString:[color substringWithRange:NSMakeRange(7,2)]] scanHexInt:&a];
CGContextSetRGBFillColor(context,r/255.0,g/255.0,b/255.0,a/255.0);