1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/iOS/SafeArea.swift

18 lines
436 B
Swift
Raw Normal View History

2022-08-07 17:41:57 +05:30
import Foundation
import UIKit
struct SafeArea {
static var insets: UIEdgeInsets {
2022-08-13 19:42:45 +05:30
let keyWindow = scene?.windows.first { $0.isKeyWindow }
2022-08-07 17:41:57 +05:30
return keyWindow?.safeAreaInsets ?? .init()
}
2022-08-13 19:42:45 +05:30
static var scene: UIWindowScene? {
UIApplication.shared.connectedScenes
2022-08-13 20:16:45 +05:30
.filter { $0.activationState == .foregroundActive }
.compactMap { $0 as? UIWindowScene }
.first
2022-08-13 19:42:45 +05:30
}
2022-08-07 17:41:57 +05:30
}