大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#pragma mark - 将16进制字符串转换成 UIColor
创新互联公司是一家专业提供黄埔企业网站建设,专注与做网站、成都网站制作、H5响应式网站、小程序制作等业务。10年已为黄埔众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。
- (UIColor *)generateColorObjectWithHex:(NSString *)hexString
{
unsigned int red = 0, green = 0, blue = 0;
NSRange range = {0, 2};
range.location = 0;
NSString *redString = [hexString substringWithRange:range];
NSScanner *redScanner = [NSScanner scannerWithString:redString];
[redScanner scanHexInt:&red];
range.location = 2;
NSScanner *greenScanner = [NSScanner scannerWithString:[hexString substringWithRange:range]];
[greenScanner scanHexInt:&green];
range.location = 4;
NSScanner *blueScanner = [NSScanner scannerWithString:[hexString substringWithRange:range]];
[blueScanner scanHexInt:&blue];
__autoreleasing UIColor *color = [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:1];
return color;
}