Seen this asked before but my example does not seem to work.
const CGFloat *toCol = CGColorGetComponents([[UIColor greenColor] CGColor]);
The array is empty from looking at it with GDB. Any hints?
Seen this asked before but my example does not seem to work.
const CGFloat *toCol = CGColorGetComponents([[UIColor greenColor] CGColor]);
The array is empty from looking at it with GDB. Any hints?
The code sample you provided should work.
Try this:
UIColor uicolor = [[UIColor greenColor] retain];
CGColorRef color = [uicolor CGColor];
int numComponents = CGColorGetNumberOfComponents(color);
if (numComponents == 4)
{
const CGFloat *components = CGColorGetComponents(color);
CGFloat red = components[0];
CGFloat green = components[1];
CGFloat blue = components[2];
CGFloat alpha = components[3];
}
[uicolor release];
This article helped me solve this problem or at least build the framework to solve it.
http://developer.apple.com/iphone/library/qa/qa2007/qa1509.html