//颜色转换 ##665522 — 三色值
+ (UIColor *)setFontColorWithString:(NSString *)color
{
NSString *cString
= [[color stringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceAndNewlineCharacterSet]] uppercaseString];
) {
return [UIColorclearColor];
}
进制来区分
if ([cString hasPrefix:@"0X"])
cString = [cString ];
if ([cString hasPrefix:@"#"])
cString = [cString ];
)
return [UIColorclearColor];
// 分为r,g,b 子字符串
NSRange range;
range.;
range.;
//r
NSString *rString = [cString substringWithRange:range];
//g
range.;
NSString *gString = [cString substringWithRange:range];
//b
range.;
NSString *bString = [cString substringWithRange:range];
// 扫描r,g,b值
unsignedint r, g, b;
[[NSScannerscannerWithString:rString] scanHexInt:&r];
[[NSScannerscannerWithString:gString] scanHexInt:&g];
[[NSScannerscannerWithString:bString] scanHexInt:&b];
return RgbHex2UIColor(r, g, b);
版权声明:本文博客原创文章,博客,未经同意,不得转载。