yattee/iOS/SafeArea.swift
2022-08-15 16:34:25 +02:00

18 lines
460 B
Swift

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