答案 0 :(得分:10)
这解决了问题
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
参考: How to get rid of the status bar background on the UIWebView?
答案 1 :(得分:6)
它仅适用于iOS 11+,因此:
if (@available(iOS 11.0, *)) {
_webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
// Fallback on earlier versions
}
答案 2 :(得分:2)
为Swift 3和WKWebView节省时间
if #available(iOS 11.0, *) {
webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never;
}
答案 3 :(得分:0)
在VC self.automaticallyAdjustsScrollViewInsets = false
viewDidLoad
您也可以在故事板中设置