How to get RGB values from UIColor?

defmech picture defmech · Jan 12, 2009 · Viewed 85.8k times · Source

I'm creating a color object using the following code.

curView.backgroundColor = [[UIColor alloc] initWithHue:229 saturation:40 brightness:75 alpha:1];

How can I retrieve RGB values from the created color object?

Answer

Teetotum picture Teetotum · Oct 21, 2011

In iOS 5 you could use:

CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha =0.0;
[multipliedColor getRed:&red green:&green blue:&blue alpha:&alpha];