IOS: Colors defined in Interface Builder other than colors in web view

We are creating an iOS application that partially uses UIWebView to display some interface elements. I noticed that the colors that are defined on the Storyboard render differently than colors with the same values ​​in the web view. The following screenshot shows three color examples on the storyboard and in the emulator: #00C2F0 , #00843C and #FF008F .

offset colors Interface Builder and Emulator

In the left square, each color is displayed as CSS background-color within the UIWebView , the right square shows the color assigned as the UIView background, directly through the Interface Builder.

When I take a screenshot and measure the color values ​​in Photoshop, the color shown in the UIWebView is exactly the same as defined (that is, exactly matches the hex color values ​​shown above), while the color shown through the UIView is offset.

I read several posts about “wrong” colors in iOS that explain this “problem” due to color management in order to have a consistent look across all devices (like here or here ). Although this sounds quite reasonable, it does not explain inconsistent visualization using different controls.

Is there anything I can do to match colors between iOS native views and colors displayed in UIWebView ?

+5
source share
1 answer

Finally, I solved my problem: the reason was not UIWebView specific, as I expected, but caused by the fact that the colors assigned with Interface Builder were in the sRGB color space. Switching to "Generic RGB" and then reassigning the hexadecimal color values ​​resolved my problem.

color space for color selection

This question and answer was very useful (I believe that the duplicate flag is unfounded).

+8
source

Source: https://habr.com/ru/post/1234522/


All Articles