Fix applying safe area insets on iOS

This commit is contained in:
Arkadiusz Fal
2022-08-07 14:11:57 +02:00
parent bc4b5fefe8
commit 50424c8dbf
4 changed files with 25 additions and 14 deletions

15
iOS/SafeArea.swift Normal file
View File

@@ -0,0 +1,15 @@
import Foundation
import UIKit
struct SafeArea {
static var insets: UIEdgeInsets {
let keyWindow = UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene }
.first?
.windows
.first { $0.isKeyWindow }
return keyWindow?.safeAreaInsets ?? .init()
}
}