Black area on UIWebView during load

前端 未结 5 1859
[愿得一人]
[愿得一人] 2021-02-05 06:34

I noticed that my UITabBar gets a dark-gray color when I preform loadRequest in my UIWebView.

If I scroll my WebView

5条回答
  •  忘掉有多难
    2021-02-05 06:59

    I must disagree with the suggested solutions here. The recommended solution of setting the opaque and backgroudColor silently hides the real problem. If you do that, then the front-most UIWebBrowserView won't cover the entire frame with the black rectangle, and will be transparent -> but the area that was previously black will remain unused, and your content won't be displayed there.

    I extracted the UIWebBrowserView and printed out its descriptions when resizing, and it seems to me that it uses rounded values for its content rectangle. As the view's frame bounds are defined as CGFloat you get rounding issues when you scale the web browser view window (resizing the wrapping view's height/width to a non-integral values).

    I managed to fix this problem through rounding the setFrame arguments of my UIWebView:

    UIWebView *myWebView;
    ....
    [myWebView setFrame:CGRectMake(newX, newY, floor(newWidth), floor(newHeight)];
    

提交回复
热议问题