Hi.
When using the brand new iPhone Duo simulator I found a weird thing. When my app is running on the left side in a split view, the tab bar is appearing on the left side. But when I print the safe area of the window, it showed
▿ UIEdgeInsets
- top : 0.0
- left : 0.0
- bottom : 34.0
- right : 0.0
But isn't the left inset supposed to be 469-385 = 84?
When it's running on the right side, the safe area insets seems to be correct:
▿ UIEdgeInsets
- top : 0.0
- left : 0.0
- bottom : 34.0
- right : 84.0
Here's how I get the safe area insets. Please correct me if I'm using a wrong way.
extension UIApplication {
var currentScene: UIWindowScene? {
return connectedScenes.first as? UIWindowScene
}
}
extension UIApplication {
var currentKeyWindow: UIWindow? {
currentScene?.windows.filter { $0.isKeyWindow }.first
}
}
// Somewhere in my code
static var safeAreaInsets: UIEdgeInsets {
let window = UIApplication.shared.currentKeyWindow
let insets = window?.safeAreaInsets ?? .zero
return insets
}
Thank you guys so much for reading.