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 help!!!!
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!
If anyone is having this issue while using UIKit
with SwiftUI
in a UIViewRepresentable
or UIViewControllerRepresentable
, try adding this modifier to the view:
.ignoresSafeArea(.all)
Example with pseudo-code:
UIViewRepresentableView()
.ignoresSafeArea(.all)
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 help!!!!
The truth is I have another viewController's view embed in my NavigationController, that viewController's view did not optimized for iPhone X, after optimized, everything's doing all right.
Thank you all guys!
请务必为正在呈现的 VC 设置 modalPresentationStyle = .fullScreen -> 然后可能遵循其他答案以将其绑定到超级视图而不是安全区域
Try to config insetsLayoutMarginsFromSafeArea and contentInsetAdjustmentBehavior.
if #available(iOS 11.0, *) {
scrollView.insetsLayoutMarginsFromSafeArea = false
scrollView.contentInsetAdjustmentBehavior = .never
}
I have faced the same issue and tried all above solutions.
It killed couple of days, finally I found issue in my app ie, we are adding view controllers as subviews to root view controller and they enabled in viewDidAppear
guard let TabBarVC = self.storyboard?.instantiateViewController(withIdentifier: "MainTabController") as? MainTabController else {return}
addChild(TabBarVC)
TabBarVC.view.translatesAutoresizingMaskIntoConstraints = false
I removed TabBarVC.view.translatesAutoresizingMaskIntoConstraints = false
Then above solutions started working
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.