I am loading an HTML string into a UIWebView in order to be able to view rich text. So far, so good. But I have one small problem: in my Nib file, I set the background attribute
Use this an addition to your code
[myWebView setBackgroundColor:[UIColor greenColor]];
[myWebView setOpaque:NO];
[myWebView loadHTMLString:myString baseURL:nil];
UIWebView *webview =[[UIWebView alloc];
[webview setBackgroundColor:[UIColor whiteColor]];
webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
Set the background color in your html itself using css markup.
Or, set the webview's opaque
property to NO
.. and set the background of the view underneath to green.
UIWebView
themselves don't seem to understand background color-- since they are rendering documents.
Tested in Xcode8 and Swift 3
self.webView.isOpaque = false;
self.webView.backgroundColor = UIColor.clear