开发者

How do UIWebView and UIScrollView manage RGB and hexa Colors?

开发者 https://www.devze.com 2023-02-25 06:18 出处:网络
I am encountering a strange problem : I added a UIWebView in a UIScrollView. I tried to apply a background color for both.

I am encountering a strange problem :

I added a UIWebView in a UIScrollView. I tried to apply a background color for both.

  • For the UIScrollView I used Interface Builder and I specified a RGB coded color : 255 0 0 (100% red).

  • For the UIWebView I specified a Hexa coded color by using :

    [self.myWebView loadHTMLString:@"<style>body {background-color:#FF0000; color:#FFFFFF;}</style>text"];
    

Well, it seems the both item don't understand colors (which are equals : #FF0000 <=> RGB(255, 0, 0)) the same way.

Actually, I get a darker red color in my UIScrollView, and something which looks like a real 100% red in my UIWebView.

Two important things :

  • I do not apply any opac开发者_StackOverflowity or alpha property on both of UIScrollView and UIWebView
  • When I try to specify #000000 / RGB(0, 0, 0) or #FFFFFF / RGB(255, 255, 255), I get the exact same color in both of my View.

So here is my question :

Is there any difference between the way the both class manage colors ?

Or any difference between RGB and Hexa colors ?


There should be no difference. I just recreated you example and it does look exactly the same. Look at these screenshots below. I load the webview like this:

[self.webView loadHTMLString:
 @"<html><body style='background-color:#FF0000; color:#FFFFFF;'>text</body></html>" baseURL:nil];

The color picker sets the color of the UIScrollView.

There must be something in your code or something about the webview and your css that alters the color.

How do UIWebView and UIScrollView manage RGB and hexa Colors?

How do UIWebView and UIScrollView manage RGB and hexa Colors?

How do UIWebView and UIScrollView manage RGB and hexa Colors?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号