yattee/iOS/SafeArea.swift

16 lines
402 B
Swift
Raw Normal View History

2022-08-07 12:11:57 +00:00
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()
}
}