background color in above (bounce part) of UIWebView
Asked Answered
J

3

5

I think this shouldn't be a big problem, but I can't find the solution on my own. As always :p I have an UIWebView that has background color set to clearColor but when I try to scroll down too much I get the "bouncing area" above loaded HTML in dark gray color. I would like to change this to transparent/white. Is there any way of changing this?
Digression: I read that classes inheriting UIScrollView can have property bounce = NO and then they won't show the bouncing area at all. Even if UIWebView was inheriting that class I wouldn't like to stop it from bouncing, just "bounce it in white" so to speak...

Thanks a lot,
Luka

Jard answered 10/3, 2011 at 12:33 Comment(0)
H
8

Take a look at the following answer

Remove gradient background from UIWebView?

Hoodoo answered 10/3, 2011 at 12:54 Comment(0)
R
4

Set the webview's background colour and set opaque to NO:

[self.webView setBackgroundColor:[UIColor whiteColor]];
[self.webView setOpaque:NO];

Or try setting clear color as background:

[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque:NO];
Randy answered 9/12, 2014 at 13:1 Comment(0)
J
0

@Ladislav: thanks for pointing me to the right subject :) Now, the following post Remove gradient background from UIWebView? is exactly what I needed, so I am sorry I opened the new thread. I searched the forum but since there is no name for this gradient, bounce background or background I couldn't find it earlier.

The summary would be:

1.Setting the backgroundColor of web view to clearColor !in code! cause in interface builder is not producing the wanted result.

myWebView.backgroundColor = [UIColor clearColor];

this line will only make the "overscroll" background look lighter, but to remove it totally (make it transparent/white) we need to hide all imageViews found in subViews of our myWebView:

for (UIView* subView in [self.myWebView subviews])
{
    if ([subView isKindOfClass:[UIScrollView class]]) {
        for (UIView* shadowView in [subView subviews])
        {
            if ([shadowView isKindOfClass:[UIImageView class]]) {
                [shadowView setHidden:YES];
            }
        }
    }
}

Thanks everyone, I wish you a great weekend

Jard answered 11/3, 2011 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.