iphone - UIWebView背景设置为Clear Color,但不透明

标签 iphone objective-c ios cocoa-touch uiwebview

我正在使用 iOS SDK 最新版本和 XCode 4.2 开发一个 iOS 4 应用程序。

我有一个带有 UIWebView 的 XIB,其中 Alpha = 1.0Background 设置为 Clear Color 并且 <未设置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 setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];

关于iphone - UIWebView背景设置为Clear Color,但不透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8667150/

相关文章:

objective-c - 将文本文件中的坐标加载到 NSMutableArray 中

ios - 如何在 Objective C 中将 CBCharacteristic.value 转换为 NSString

ios - 如何更改 iOS UITextField 中的行数

iPhone UI addSubview导致并发异常

iphone - 没有符合条件的 bundle 标识符提交错误

objective-c - 从 View 调用类方法给出 : "Unrecognized selector sent to class"

ios - GPUImageMovie 不尊重 imageOrientation

ios - WebRTC 中的调用组视频

iPhone - 如何在进入前景后恢复帧大小?

iphone - 可以将 Core Data 与不同的预填充 sqlite 数据库一起使用吗?