Grey bar on top of UIWebView in iOS 10

2019-06-06 23:11发布

When I drag a UIWebView from the Object Library in Xcode, I get a UIWebView with this dark grey bar at the top:

enter image description here

What is that and how can I get rid of it?

标签: ios uiwebview
3条回答
forever°为你锁心
2楼-- · 2019-06-06 23:42

You need put self.automaticallyAdjustsScrollViewInsets = NO; in ViewDidLoad

The other choice is disable option Adjust Scroll View Insets in the .xib of your viewcontroller

enter image description here

查看更多
ら.Afraid
3楼-- · 2019-06-06 23:44

That dark grey color is the background color set for the UIWebView. This will show if a webpage is smaller than the frame of the web view. You won't see it if you change the background color to white or transparent.

查看更多
够拽才男人
4楼-- · 2019-06-06 23:51

_webView.scrollView.contentInsetAdjustmentBehavior = .never

This should work if you have a WKWebView/UITableView/ScrollView. Add this in ViewDidLoad. This will make the status bar overlap the content without adding a extra white space in the status bar.

查看更多
登录 后发表回答