Original white uiwebview iphone look

My main view is uiwebview. It is white for a second before it can display the HTML code generated by the application.

Is there a way to make a black and white uiwebview or another color before rendering it? A flash of white is not part of my plan for a smooth visual transition.

Objective-C or MonoTouch answers are fine, I'm bilingual.

+7
iphone uiwebview
source share
4 answers

One thing you can try is to place the UIView with the desired color and place it above the UIWebView with the same width and height. Then, in the webViewDidFinishLoad method, set the UIView to hidden.

+3
source share

Another thing to try is to make the view transparent:

webView.backgroundColor = [UIColor clearColor]; webView.opaque = NO; 

This leads to additional layout work, so you can reset to use these values ​​for something more friendly for this after loading the web view in webViewDidFinishLoad:

 - (void) webViewDidFinishLoad:(UIWebView *)webView { webView.backgroundColor = [UIColor blackColor]; webView.opaque = YES; } 
+31
source share

I still can not comment on the answer. @Steve, it's actually possible to do this with storyboards.

Put the UIView in the UIWebView and:

 // Can be set in the storyboard bottomView.backgroundColor = [UIColor yellowColor]; webview.alpha = 0; 

Remember that after loading through JS there are many page loads, and you can still leave a white page a few seconds after

 - (void) webViewDidFinishLoad:(UIWebView *)webView { webView.alpha = 1; } 
0
source share

To add to Steve Madsen's answer (since I cannot comment yet). If you installed UIWebView in Interface Builder, you cannot set the alpha value to 0.0, but what you can do is raise the color set to set the background color (white, black, gray, it doesn't matter), then set the opacity of this color is up to zero percent, and it works.

0
source share

All Articles