Pheel Pheel - 1 year ago 76
CSS Question

UIWebView's content background color not transparent

I'm using an UIWebView to load some HTML text from a plist.

I managed to make its background transparent using

webView.opaque = NO;
webview.backgroundColor = [UIColor clearColor];

but the content, which is the text loaded from the plist, is shown with a disturbing white background.

I'm loading it using

NSString *descr = [NSString stringWithFormat:@"<html><head><style> body{font-size:16; font-family: Helvetica; color: black;} strong{font-family: Arial; font-weight: bold; font-size:16} .bg{background:transparent;}</style></head><body><div class='bg'>%@</div></body></html>",[item valueForKey:@"description"]];
[webView loadHTMLString:descr baseURL:nil];

I've tried setting the
class background color to
, but nothing worked.

Also tried setting
webView.scrollView.backgroundColor : [UIColor clearColor];

Any advice on how to get the UIWebView's content background transparent?

Answer Source

try this !

[webView setOpaque:NO];
webView.bakgroundColor = [UIColor clearColor];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download