Safe area covered the view, can not remove

Bi Brian picture Bi Brian · Mar 14, 2018 · Viewed 11.1k times · Source

I don't know why the safe area covered my view on the iPhone X, simulator, but in xCode's view debug it seems ok. Is there any option to hide the safe area view or remove it? thanks in advance! Via the view debug I can see no view or nothing covered my view, it's all right, really strange.

I added this myView in the storyboard which turned on the safe area layout guide. I tried set additionalSafeAreaInsets.top additionalSafeAreaInsets.bottom to zero but it's not working.

Here is how I do the constraints:

func setupGroupBView() {
    self.groupBView = myView.create()
    self.view.addSubview(groupBView) 
    self.groupBView.snp.makeConstraints({ (make) in
        make.width.centerX.centerY.equalTo(self.view)
        make.height.equalTo(screenHeight)
    }) 
}

I tried set the myView's top, bottom to the controller's view.top view.bottom to -44, -34 but still it won't work.

please check this picture that shows the reality!

Please help!!!!

Answer

Rajat Mishra picture Rajat Mishra · Mar 14, 2018

You can disable safe area layout guide from storyboard for particular view controller.

Select View Controller -> File Inspector (first tab) -> Use safe area layout guides (uncheck the checkbox).

You can also change it programmatically in viewDidLoad().

view.insetsLayoutMarginsFromSafeArea = false

Hope this Helps!