Search code examples
iosobjective-cuicolor

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.


Solution

  • Simply divide all you color values by 255:

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