方法1、让UIWebView背景透明。
webView.backgroundColor = [UIColor clearColor];webView.opaque = NO;[webView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"webbg.png"]]];
方法2:
先将webView的frame设为0, 在页面加载完成后再将frame设为原来大小.
方法3:
在viewDidLoad中,在WebView上面覆盖一个背景视图。
self.webView=[[[UIWebView alloc]initWithFrame:self.view.bounds]autorelease]; [self.webView loadRequest:request]; [self.view addSubview:self.webView]; UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"gatewaybg.png"]]; imageView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height); [self.view addSubview:imageView];
- (void)webViewDidFinishLoad:(UIWebView *)webView{ // WebView放到最上层 [self.view bringSubviewToFront:self.webView]; // 或者可以把背景图移除 [self.webView removeFromSuperview];}