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

WBOY
Release: 2016-06-24 11:46:22
Original
1233 people have browsed it

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"]]];
Copy after login


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];
Copy after login

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];}
Copy after login


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template