Dogweather Dogweather - 4 months ago 27
iOS Question

How to prevent initial white flash when showing a UIWebView?

I use a

UIWebView
to show an "About" screen by displaying a bundled HTML file. My app's view hierarchy is:
UITabBarController
/
UIViewController
/
UIWebView
.

The problem is that the HTML page has a dark background, and the very first time the tab is tapped, a white background is visible briefly before the web view is displayed. I tried setting the background color of the
UIWebView
, but that doesn't solve the problem. The problem occurs whether I load the content in
viewDidLoad
or
viewWillAppear
.

Answer
[webView setOpaque:NO];
webView.backgroundColor = [UIColor clearColor];