Home  >  Article  >  Web Front-end  >  UIWebView solves the problem of blank background when loading the page_html/css_WEB-ITnose

UIWebView solves the problem of blank background when loading the page_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:46:221253browse

During the loading process of UIWebView, a blank page will be displayed before the page is loaded. To solve this problem, the method is as follows:

Method 1. Make the UIWebView background transparent.

webView.backgroundColor = [UIColor clearColor];webView.opaque = NO;[webView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"webbg.png"]]];


Method 2:

First set the frame of webView to 0, on the page After loading is complete, set the frame to its original size.


Method 3:

In viewDidLoad, overlay a background view on the 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];

Then put the view on top or remove the background view after the WebView is loaded.

- (void)webViewDidFinishLoad:(UIWebView *)webView{    // WebView放到最上层    [self.view bringSubviewToFront:self.webView];    // 或者可以把背景图移除    [self.webView removeFromSuperview];}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn