UIWebView solves the problem of blank background during page loading, while uiwebview is blank

Source: Internet
Author: User

UIWebView solves the problem of blank background during page loading, while uiwebview is blank

During UIWebView loading, a blank area is displayed before the page is loaded. To solve this problem, follow these steps:

Method 1: make the background of UIWebView 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. After the page is loaded, set the frame to the original size.


Method 3:

In viewDidLoad, overwrite 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];

After the WebView is loaded, place the view to the top or remove the background view.

-(Void) webViewDidFinishLoad :( UIWebView *) Place webView {// WebView to the top layer [self. view bringSubviewToFront: self. webView]; // You can also remove the background image from the [self. webView removeFromSuperview];}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.