-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIWindow+Extensions.swift
43 lines (36 loc) · 1.15 KB
/
UIWindow+Extensions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// UIWindow+Extensions.swift
// OYExtensions
//
// Created by osmanyildirim
//
import UIKit
extension UIWindow {
/// Initializer method with `viewController`
public static func oy_init(_ viewController: UIViewController) -> UIWindow {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = viewController
window.makeKeyAndVisible()
return window
}
/// `UIWindow.oy_size` → output → (width = 430, height = 932)
public static var oy_size: CGRect {
UIScreen.main.bounds
}
/// `UIWindow.oy_width` → output → 430
public static var oy_width: CGFloat {
UIScreen.main.bounds.width
}
/// `UIWindow.oy_height` → output → 932
public static var oy_height: CGFloat {
UIScreen.main.bounds.height
}
/// `UIWindow.oy_safeAreaTop` → output → 59
public static var oy_safeAreaTop: CGFloat {
UIApplication.oy_keyWindow?.safeAreaInsets.top ?? 0
}
/// `UIWindow.oy_safeAreaBottom` → output → 34
public static var oy_safeAreaBottom: CGFloat {
UIApplication.oy_keyWindow?.safeAreaInsets.bottom ?? 0
}
}