我正在使用iOS SDK最新版本和XCode 4.2开发一个iOS 4应用程序。
我有一个带有UIWebView
的XIB,Alpha = 1.0,Background设置为Clear Color,Opaque未设置。在这个XIB上,我用下面的代码设置了一个图像作为背景:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"AboutBackground.png"]];
self.view.backgroundColor = background;
[background release];
}
return self;
}
UIWebView
显示的是静态html:
<html><head></head><body style=\"margin:0 auto;text-align:center;background-color: transparent; color:white\">...</body></html>
在iOS 5模拟器上,它的背景是透明的,但在iOS 4设备上是灰色的。
有什么线索吗?
发布于 2011-12-29 19:17:07
同时设置:
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
发布于 2013-12-09 20:46:31
/*for ios please set this*/
[webViewFirst setOpaque:NO];
/*for html please set this*/
<body style="background:none">
发布于 2011-12-29 19:15:57
除了将webview的背景设置为透明颜色外,还要确保将opaque设置为false。
https://stackoverflow.com/questions/8667150
复制相似问题