yattee/iOS/SafeArea.swift

18 lines
460 B
Swift
Raw Normal View History

2022-08-07 12:11:57 +00:00
import Foundation
import UIKit
struct SafeArea {
static var insets: UIEdgeInsets {
2022-08-13 14:12:45 +00:00
let keyWindow = scene?.windows.first { $0.isKeyWindow }
2022-08-07 12:11:57 +00:00
return keyWindow?.safeAreaInsets ?? .init()
}
2022-08-13 14:12:45 +00:00
static var scene: UIWindowScene? {
UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene }
.first
}
2022-08-07 12:11:57 +00:00
}