Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Taking an RGB color and normalizing it with UIColor on the iPhone

I'm looking for a straight forward way to convert a color from RGB, grabbing it from a tool like Photoshop, then convert it to a UIColor. Since UIColor uses normalized gamut of 0.0 to 1.0 for each color space, I'm not sure how this is done.

Thanks for the solution.

like image 509
Coocoo4Cocoa Avatar asked May 04 '09 17:05

Coocoo4Cocoa


1 Answers

Your values are between 0 and 255. Use them to create a UIColor:

float r; float g; float b; float a;

[UIColor colorWithRed:r/255.f
                green:g/255.f
                 blue:b/255.f    
                alpha:a/255.f];
like image 160
Kriem Avatar answered Oct 27 '22 01:10

Kriem