在我的xib中,我有一个UIWebView控件,我需要使其背景透明,以便我制作
- 背景=clearColor和
- 未选中不透明复选框
它在iOS 5.0&更大,但在iOS<5.0背景白色即将出现。如何解决此问题?
- (void)makeBodyBackgoundTransparent {
for (UIView *subview in [webView subviews]) {
[subview setOpaque:NO];
[subview setBackgroundColor:[UIColor clearColor]];
}
[webView setOpaque:NO];
[webView setBackgroundColor:[UIColor clearColor]];
}
将web视图的背景设置为透明颜色,同时确保将opaque设置为false。
在iOS中<5.0你也必须直接在html代码中设置背景颜色。
将其包含在Webview的HTML代码中:
<body style="background-color: transparent;">
并设置webview的背景颜色和不透明值:
[self.webView setBackgroundColor:[UIColor clearColor]];
[self.webView setOpaque:NO];