【发布时间】:2012-01-29 19:54:33
【问题描述】:
我正在使用 iOS SDK 最新版本和 XCode 4.2 开发一个 iOS 4 应用程序。
我有一个带有UIWebView 的 XIB,Alpha = 1.0,Background 设置为 Clear Color 和 Opaque strong> 未设置。在这个 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 上放置一个 UIImageView 并将其设置为您的图像。
-
感谢您的回答,但网页视图并没有填满整个屏幕。
标签: iphone objective-c ios cocoa-touch uiwebview