无法在iPhone SDK中更改UIWebView的背景 [英] Can't change background for UIWebView in iPhone SDK

查看:128
本文介绍了无法在iPhone SDK中更改UIWebView的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法改变 UIWebView的背景颜色

IB效果中没有设置颜色 UIWebView 行为:在加载实际内容之前,它显示为白色(在加载内容和呈现内容之间导致白色闪烁)。

None of the colors set in IB effect UIWebView behavior: before actual content is loaded it shows as up as white (causing a white flash between the moment it is loaded and content is rendered).

以编程方式设置背景颜色也不起作用。

Setting background color programmatically does not do anything either.

这是代码:

@interface Web_ViewViewController : UIViewController {

    UIWebView *web;
}

@property (nonatomic, retain) IBOutlet UIWebView *web;
@end

....
-(void)viewDidLoad {
    super viewDidLoad;

    web.backgroundColor = [UIColor blueColor];
    NSURL *clUrl = [NSURL URLWithString:@"http://www.apple.com"];
    NSURLRequest *req = [NSURLRequest requestWithURL:clUrl];

    [web loadRequest:req];
}


推荐答案

您可以设置不透明属性将webview设置为NO,然后设置下方视图的背景颜色。

You can set the opaque property of the webview to NO and then set background color of the view beneath.


[webView setOpaque:NO];

这篇关于无法在iPhone SDK中更改UIWebView的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆