I have a single view app. I define two UIView
instances inside that single view. I want both to have same color.
For first view I define it in Interface Builder and pick a color. I want #999999
(grey). New color picker has possibility to enter hex color values so it is easy to enter: 999999
.
For the second view, I define it by setting background color of second view. I set same #999999
color using [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1]
.
Simple calculation: #99 -> 153 -> 153/255 == 0.6.
So far good.
However resulting colors are different. Why? This feels like a bug in xcode. After debugging resulting colors:
Color defined in IB: UIDeviceRGBColorSpace 0.529648 0.529632 0.529641 1
Color defined in code:UIDeviceRGBColorSpace 0.6 0.6 0.6 1
UPDATE:
I know about "duplicates" to this question. They have one thing in common. They properly identified the problem but failed miserably to solve it. It tested developer color pickers from Panic and Skala. They have same problem. And as insult to injury they offer copy color as hex values. Guest what, numbers there are not affected by color profile at all. So for example color #999
they provide exactly 0.6
for each color component. Unfortunately, if color is used directly it has color profile attached and resulting color is different. Only way to get exact RBG color is to use "safe web colors" where resulting color is with generic RGB color profile, in other words not affected. Problem is that safe web colors doesn't contain all colors our designers use.