Search code examples
iphonecocoa-touchuicolor

UIColor Limitations or Bugs on iPhone 3.0


I'm working with some colors, and they don't appear to be correct at all. The attached Images show the expected result, and the actual simulator, and on-device result. As you can see there appears to be quite a difference between what the Gimp thinks RGB(0, 16, 60) is and what the output I'm getting from [UIColor colorWithRed:0.0 green:16.0 blue:60.0 alpha:1.0];

Since my alpha is 1.0 I don't believe I have any color mixing with the background going on.

Any suggestions on what's going on here are welcome.alt text http://img200.imageshack.us/img200/3710/picture4uu.png

iPhone Result:

alt text http://img33.imageshack.us/img33/9264/picture3xb.png


Solution

  • Just about every color method in iPhone OS takes a value from 0.0–1.0, not 0.0–255.0. To get the color you're looking at in The GIMP, divide each of your values by 256; thus, the correct UIColor method call would be [UIColor colorWithRed:0.0 green:0.0625 blue:0.2344 alpha:1.0].