For some reason, the UIWebDocumentView uses neither [UIColor lightGrayColor] nor [webview backgroundColor]. Here is a snippet of code following zonble's answer:
- (void)loadView
{
...
[self setView: webview];
self.mCoverView = [[UIView alloc] initWithFrame:aRectangleLargeEnough];
[webview addSubview:self.mCoverView];
UIColor * matchingGray = [[UIColor alloc] initWithRed:204./255.
green:204./255.
blue:204./255.
alpha:1.];
[self.mCoverView setBackgroundColor:matchingGray];
[matchingGray release];
[self.mCoverView release];
...
}
And in both -webViewDidFinishLoad: and -didFailLoadWithError:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
...
[self.mCoverView removeFromSuperview];
sself.mCoverView = nil; // <- @property (nonatomic. retain)
...
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
...
[self.mCoverView removeFromSuperview];
self.mCoverView = nil; // <- @property (nonatomic. retain)
...
}
And to add a fade-out once the web page is loaded, replace the -removeFromSuperview by:
{
...
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];
[self.mCoverView setAlpha:0.f]; // Will fade out
[UIView commitAnimations];
self.mCoverView = nil; // <- @property (nonatomic. retain)
...
}