开发者

How to set the background color for UIWebView [duplicate]

This question already has answers here: How to make a transparent UIWebView (8 answers) Closed 9 years ago.

I want to change the background color of the webview. Not for the HTML document it display but for the actual scroll view which can be scrolled. If you scroll a web view you see a gray background color. I have tried below code for this but not working for me. Actually I want to make it transparent.

    [detailWebV setOpaque:NO];
    detailWebV.backgroundColor = [UIColor clearColor];

开发者_StackOverflowThanks in advance!


Try this

myWebView.opaque = NO;
myWebView.backgroundColor = [UIColor clearColor];
[myWebView loadHTMLString:
@"<html><body style='background-color: transparent'>
       Content Here</body></html>" baseURL:nil];


Another way is to set it by using JavaScript:

[yourWebView stringByEvaluatingJavaScriptFromString:@"document.body.style.background = '#000000';"];


the following has worked for me . This is what I wanted , when I scroll down the web view , the background should be transparent .

     [webV setOpaque:YES];
     webV.backgroundColor = [UIColor clearColor];

Thank you all !!!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜