Search code examples
iosswiftuiwebviewuitabbarwkwebview

Prevent Tab Bar from cutting off WKWebView text


Our UITabBar is cutting off the bottom of our WKWebView text.

Our Storyboard view has a few labels at the top of the screen and a WKWebView set below those labels programatically. It works great but you can't scroll to the end of the WKWebView to see the last line of the text.

I believe this doesn't happen with UIWebView but that API is deprecated.

I understood automaticallyAdjustsScrollViewInsets to be the solution but apparently that doesn't work in this case.

Have tried setting Extend Edges \ Under Bottom Bars to false on the Storyboard. This comes close to solving the issue - the scrolling issue is resolved. Only issue is the Tab Bar then changes color to a darker color and I can't seem to get that to revert to the default lighter grey metallic color.

What is the correct way to do this?


Solution

  • WKWebView contains UIScrollView. UIScollView has contentInset property. https://developer.apple.com/reference/uikit/uiscrollview/1619406-contentinset
    Use this property to add to the scrolling area around the content. The unit of size is points. The default value is UIEdgeInsetsZero.