该方法把转入来的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;
}
本文介绍了一个将UIColor对象转换为RGB颜色值的方法。通过获取CGColor组件并将其映射到0-255范围内的整数值来实现。适用于需要从UIColor获取精确RGB值的应用场景。
2377

被折叠的 条评论
为什么被折叠?



