make WKWebview "real" fullscreen on iPhone X (remove safe area from WKWebView
You can also extend safeAreaInsets from WKWebView.
extension WKWebView {
override open var safeAreaInsets: UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
}
Here is one more solution without overriding and executing javascript:
webView.scrollView.contentInsetAdjustmentBehavior = .never
In my case, it worked great.
Objective-c version:
[webView.scrollView setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];
After a little try and error, this is the solution I came up with.
Subclass WKWebView and create a custom class. Overwrite safeAreaInsets
:
import Foundation
import WebKit
class FullScreenWKWebView: WKWebView {
override var safeAreaInsets: UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
}