You need to set the background color to clear as well as making the webView opaque. This doesn't seem to work if you don't also change the backgroundColor to clear.
I've had this problem before, and it's related to the content inset of your UIWebView. This black area appears wherever you have a bottom inset set on the scrollview. I was able to fix this by setting the opaque property of the webview:
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:
You need to set the background color to clear as well as making the webView opaque. This doesn't seem to work if you don't also change the backgroundColor to clear.
Set for UIWebView opaque NO and clear background color simultaneously:
I've had this problem before, and it's related to the content inset of your UIWebView. This black area appears wherever you have a bottom inset set on the scrollview. I was able to fix this by setting the
opaque
property of the webview:I must disagree with the suggested solutions here. The recommended solution of setting the
opaque
andbackgroudColor
silently hides the real problem. If you do that, then the front-mostUIWebBrowserView
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 myUIWebView
:In swift,
webView.opaque = false