CGFloat R=0.0,G=0.0,B=0.0,A= 0.0;
CGColorRef color = _innerColor.CGColor;
int numComponents = CGColorGetNumberOfComponents(color);
if (numComponents==4)
{
const CGFloat *components = CGColorGetComponents(color);
R = components[0];
G = components[1];
B = components[2];
A = components[3];
}
CGColorRef color = _innerColor.CGColor;
int numComponents = CGColorGetNumberOfComponents(color);
if (numComponents==4)
{
const CGFloat *components = CGColorGetComponents(color);
R = components[0];
G = components[1];
B = components[2];
A = components[3];
}
本文介绍了一段关于如何从CGColorRef中获取RGBA值的代码实现。通过判断颜色组件的数量,能够正确提取并赋值给对应的R、G、B、A变量。此方法适用于需要处理CGColor颜色模型的应用场景。
654

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



