Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-c HTML->RGB color not correct in UIColor

I need to use custom colors in my app. I've found some nice HTML colors and converted them to RGB values then apply them with:

[UIColor colorWithRed:235 green:242 blue:212 alpha:1]

The problem is the resulting color in my app isn't correct. Sometime it's just white and other times it's just way off. Red could be yellow etc.

Has anybody come across this before? Am I converting the colors incorrectly or something.

like image 276
jim Avatar asked Sep 09 '11 11:09

jim


1 Answers

Simply divide all you color values by 255:

[UIColor colorWithRed:235/255.0f green:242/255.0f blue:212/255.0f alpha:1]
like image 196
nubbel Avatar answered Sep 28 '22 00:09

nubbel