I've recently been tearing my hair out over trying to set the same background color for views styled using Interface Builder, and views styled programatically using [UIColor colorWithRed: green: blue: alpha:]
. Despite setting the same RGB values, the views styled in IB were a slightly different color shade to those styled in code.
I finally realised it was to do with color spaces - when I examined the views in IB using the color picker, it showed the color space was set to 'sRGB' rather than the default of 'Generic RGB' which UIColor
uses. I never changed the color space setting myself. I then realised what is happening is that when you manually type in the RGB values in the color picker, it changes the color space to 'sRGB' without you knowing therefore giving a different color. However if you use the mouse to drag the slider bars to change the values then the color space remains at 'Generic RGB' and all is well.
Is this a bug, or am I misunderstanding the color picker? I'm using Xcode 6.1.
A solution is to use "Device RGB" and not "Generic RGB".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With