您的位置:首页 > 产品设计 > UI/UE

ios UIColor转化为RGB值

2017-07-17 14:40 274 查看
该方法把转入来的UIColor对像转化为RGB对应颜色值输出,大小在0-1之间
-(RGBValue)readRGBForUIColor:(UIColor*)color{

const CGFloat *components = CGColorGetComponents(color.CGColor);
Byte b = components[2] * 255;
Byte g = components[1] * 255;
Byte r = components[0] * 255;

RGBValue rgb;
rgb.blue = b;
rgb.green = g;
rgb.red = r;

NSLog(@"red:%x\ngreen:%x\nblue:%x",r,g,b);
return rgb;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  RGB UIColor ios xcode color