IOS,十六进制颜色和RGB颜色的宏定义

16进制颜色值宏定义。app

 //调用
 NSString *str = model.Color;    
 NSString *strColor = [str stringByReplacingOccurrencesOfString:@"#" withString:@""]; 
 NSMutableString *tempHex=[[NSMutableString alloc] init];  
 [tempHex appendString:strColor]; 
 unsigned colorInt = 0;
 [[NSScanner scannerWithString:tempHex] scanHexInt:&colorInt];
 _cellView.entityLable.textColor = UIColorFromRGB(colorInt);
 
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


// 2.得到RGB颜色spa

#define ZFColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
//调用 UIColor * color = ZFColor(251, 251, 251);   251,251,251的RGB颜色值表明白色
相关文章
相关标签/搜索