Open imzyf opened 6 years ago
safeAreaInsets in UIView is 0 on an iPhone X
https://stackoverflow.com/questions/47032855/safeareainsets-in-uiview-is-0-on-an-iphone-x
safeAreaInsets has the correct size in layoutSubviews()
If you're using view in a UIViewController, you can also do it in viewDidLayoutSubviews() and it should work as it did for me.
static var safeArea: UIEdgeInsets {
if #available(iOS 11.0, *) {
return UIApplication.shared.delegate?.window??.safeAreaInsets ?? UIEdgeInsets.zero
} else {
return .zero
}
}