We're building an iOS app which partly makes use of UIWebView
s to render some UI elements. I noticed, that colors which are defined on the Storyboard are rendered differently than colors with the same values in the Web View. The following screenshot shows three example colors on the storyboard and in the emulator: #00C2F0
, #00843C
and #FF008F
.
The left squares show each color rendered as CSS background-color
within a UIWebView
, the right square shows the color assigned as background to a UIView
directly through Interface Builder.
When I take a screenshot and measure the color values in Photoshop, the color shown within the UIWebView
is exactly as defined (i.e. exactly matching the hex color values given above), whereas the color shown through the UIView
is shifted.
I've read several posts about "wrong" colors on iOS, which explain this "issue" due to color management with the goal to have a consistent visual appearance on all devices (e.g. here or here). While this sounds totally reasonable, it does not explain the inconsistent rendering through different controls.
Is there anything I can do to achieve matching colors between iOS native views and colors rendered within a UIWebView
?
I finally solved my issue: The reason was not UIWebView
-specific as I had originally assumed, but caused by the fact, that the colors assigned through Interface Builder were in sRGB color space. Changing to "Generic RGB" and then re-assigning the hex color values solved my issue.
Very helpful was this question and answer (I feel the duplicate flag is unjustified).
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