How to make a transparent UIWebView
I recommend:
webView.opaque = NO;webView.backgroundColor = [UIColor clearColor];
(setting these properties in Interface Builder will work for iOS 5.0+, but for iOS 4.3 you must set the backgroundColor in code)
And include this into your HTML code:
<body style="background-color: transparent;">
Use the recursive method below to remove gradient from UIWebView:
[webView setBackgroundColor:[UIColor clearColor]];[self hideGradientBackground:webView];- (void) hideGradientBackground:(UIView*)theView{ for (UIView * subview in theView.subviews) { if ([subview isKindOfClass:[UIImageView class]]) subview.hidden = YES; [self hideGradientBackground:subview]; }}
Swift update:
webView.opaque = truewebView.backgroundColor = UIColor.clearColor()
And again, don't forget to set
<body style="background-color: transparent">
Or better still, instead of an inline style, in your style sheet:
body { background-color: transparent}