如何从UIColor获取RGB值?
问题描述:
我正在使用以下代码创建一个颜色对象。
I'm creating a color object using the following code.
curView.backgroundColor = [[UIColor alloc] initWithHue:229 saturation:40 brightness:75 alpha:1];
如何从创建的颜色对象中检索RGB值?
How can I retrieve RGB values from the created color object?
答
const CGFloat *colors = CGColorGetComponents( curView.backgroundColor.CGColor );
这些链接提供了更多详细信息:
These links provide further details:
- UIColor Reference
- CGColorGetComponents reference