CGFloat R, G, B;
CGColorRef color = [UIColor clearColor].CGColor;
// Returns the number of color components (including alpha) associated with a Quartz color
NSInteger numComponents = CGColorGetNumberOfComponents(color);
if (numComponents == 4)
{
const CGFloat *components = CGColorGetComponents(color);
R = components[0];
G = components[1];
B = components[2];
}
NSLog(@"r= %f,g=%f,b=%f",R,G,B);
输出为 :r=0.000000,g=0.000000,b=0.000000
本文介绍如何使用Objective-C从UIColor的clearColor中获取RGBA组件,并通过示例代码展示如何读取颜色的红、绿、蓝分量。
658

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



