WKWebView+contentInset makes content size wrong
The problem is that WKWebView
always seems to use its frame as its viewport size, neglecting to subtract the scrollView's contentInset
. I was able to find a workaround by stephan-leroux.
The idea is to set the WKWebView's frame to the desired viewport size, either manually or using autolayout constraints. To restore the "scroll-under" effect of contentInset
, disable the scrollView's masksToBounds
:
wkWebview.scrollView.layer.masksToBounds = NO;