9
votes

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.

1
As I often struggled with this simple task too I have created a simple and straightforward online tool for this: color.to Just paste your color in any of the supported formats (RGB, HEX, HSV or CMYK) and copy the output.jeppeb

1 Answers

36
votes

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];