Search code examples
iphoneiosios5uicolor

Creating colors with UIColor


I am trying to create the below color in Xcode, but cannot seem to get it to match?

enter image description here

I have tried the following:

setBackgroundColor:[[UIColor alloc] initWithRed:0 green:47 blue:135 alpha:1]];

Is there something I am doing wrong, or should change the color does not match what I expect?


Solution

  • Try this

    setBackgroundColor:[[UIColor alloc] initWithRed:15/255.0f green:47/255.0f blue:135/255.f alpha:1]];

    UIColor expects the colors to be a value between 0 and 1, so you have to divide those values by 255.