我正在使用 iOS SDK 最新版本和 XCode 4.2 开发一个 iOS 4 应用程序。
我有一个带有 UIWebView
的 XIB,其中 Alpha = 1.0,Background 设置为 Clear Color 并且 不透明。在这个 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 设备上是灰色的。
有什么线索吗?
最佳答案
也设置了:
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
https://stackoverflow.com/questions/8667150/
相关文章:
objective-c - 在 Objective-C 中大写或更改 NSString 的大小写
ios - AppDelegate 的用途是什么,我如何知道何时使用它?
objective-c - 更改 NSView 的背景颜色的最佳方法
ios - UILabel - 自动调整大小标签以适合文本?
objective-c - 是否可以在 Objective-C 中将 -init 方法设为私有(pr
iphone - 指定的权利...配置文件。 (0xE8008016)。错误 iOS 4.2