UIWebView background color

前端 未结 5 456
不知归路
不知归路 2021-01-31 01:19

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

相关标签:
5条回答
  • 2021-01-31 01:58

    Use this an addition to your code

    [myWebView setBackgroundColor:[UIColor greenColor]];
    [myWebView setOpaque:NO];
    [myWebView loadHTMLString:myString baseURL:nil];
    
    0 讨论(0)
  • 2021-01-31 01:58
    UIWebView *webview =[[UIWebView alloc];
    
    [webview setBackgroundColor:[UIColor whiteColor]];
    
    0 讨论(0)
  • 2021-01-31 02:03
    webView.opaque = NO;
    webView.backgroundColor = [UIColor clearColor];
    
    0 讨论(0)
  • 2021-01-31 02:13

    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.

    0 讨论(0)
  • 2021-01-31 02:22

    Tested in Xcode8 and Swift 3

    self.webView.isOpaque = false;
    self.webView.backgroundColor = UIColor.clear
    
    0 讨论(0)
提交回复
热议问题