1

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?

Community
  • 1
  • 1
Marcus Leon
  • 55,199
  • 118
  • 297
  • 429
  • Can you add a screenshot of current view hierarchy? https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/debugging_with_xcode/chapters/special_debugging_workflows.html – nspavlo Apr 23 '17 at 13:37

2 Answers2

3

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.

nspavlo
  • 377
  • 3
  • 12
2

Figured it out based on some other SO posts:

webView.scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, controller.tabBarController!.tabBar.frame.height, 0.0)

... maybe there is a better way (?) but this worked.

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429