A color object with grayscale and alpha values that are both 0.
Also set :
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
/*for ios please set this*/
[webViewFirst setOpaque:NO];
/*for html please set this*/
<body style="background:none">
Besides setting your webview's background to clear color, also make sure that you set opaque to false.
webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
You can try this code (i know, that it's unsafe, but it works even for ios5):
- (void)makeBodyBackgroundTransparent {
for (UIView *subview in [webView subviews]) {
[subview setOpaque:NO];
[subview setBackgroundColor:[UIColor clearColor]];
}
[webView setOpaque:NO];
[webView setBackgroundColor:[UIColor clearColor]];
}
NSString *content=@"example clear background color UIWebview";
NSString *style=[NSString stringwithformat:@"<html><head><style>body {background-color:transparent;}</style></head><body>%@</body></html>",content];
[myWebview loadhtmlstring:style baseurl:nil];
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