Is there a way to change background color for UIWebView?
None of the colors set in IB effect UIWebView behavior: before actual content is l
Yes, it seems setting the backgroundColor property has no effect on the UIWebView.
I don't have a satisfactory solution, only a workaround that you can consider.
If you don't wait for the initial HTML page to load, you might not see the initial background while the main URL is loading. So you'll need to use the UIWebViewDelegate's webViewDidFinishLoad: method. You can implement that method in your Web_ViewViewController class, and make your Web_ViewViewController conform to the UIWebViewDelegate protocol. Initially, there is still a momentary flicker of white background until the empth HTML page loads. Not sure how to get rid of that. Below is a sample:
- (void)viewDidLoad
{
[web loadHTMLString: @"" baseURL: nil];
web.delegate = self;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
static BOOL loadedMainURLAlready = NO;
if (!loadedMainURLAlready)
{
NSURL *clUrl = [NSURL URLWithString:@"http://apple.com"];
NSURLRequest *req = [NSURLRequest requestWithURL:clUrl];
[webView loadRequest:req];
loadedMainURLAlready = YES;
}
}