UIWebView background is set to Clear Color, but it is not transparent(UIWebView背景设置为Clear Color,但不透明)
问题描述
我正在使用 iOS SDK 最新版本和 XCode 4.2 开发一个 iOS 4 应用程序.
I'm developing an iOS 4 application using iOS SDK latest version and XCode 4.2.
我有一个带有 UIWebView 的 XIB,其中 Alpha = 1.0,Background 设置为 Clear Color 并且 <未设置strong>不透明.在这个 XIB 上,我使用以下代码将图像设置为背景:
I have a XIB with a UIWebView with Alpha = 1.0, Background set to Clear Color and Opaque is not set. On this XIB I setup an image as background with this code:
- (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:
The UIWebView is showing an static html:
<html><head></head><body style="margin:0 auto;text-align:center;background-color: transparent; color:white">...</body></html>
在 iOS 5 模拟器上,它的背景是透明的,但在 iOS 4 设备上是灰色的.
On iOS 5 simulator, its background is transparent, but on an iOS 4 device is grey.
有什么线索吗?
推荐答案
另外设置:
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
这篇关于UIWebView背景设置为Clear Color,但不透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIWebView背景设置为Clear Color,但不透明
基础教程推荐
- Android Volley - 如何动画图像加载? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
