-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIScreen+Extensions.swift
60 lines (49 loc) · 1.61 KB
/
UIScreen+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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// UIScreen+Extensions.swift
// OYExtensions
//
// Created by osmanyildirim
//
import UIKit
extension UIScreen {
/// `UIScreen.oy_main` → output → <UIScreen: 0x15cd083a0; bounds: {{0, 0}, {430, 932}}
public static var oy_main: UIScreen {
main
}
/// `UIScreen.oy_bounds` → output → (CGRect) (width = 430, height = 932)
public static var oy_bounds: CGRect {
main.bounds
}
/// `UIScreen.oy_size` → output → (CGSize) (width = 430, height = 932)
public static var oy_size: CGSize {
main.bounds.size
}
/// `UIScreen.oy_width` → output → 430.0
public static var oy_width: CGFloat {
oy_size.width
}
/// `UIScreen.oy_height` → output → 932.0
public static var oy_height: CGFloat {
oy_size.height
}
/// `UIScreen.oy_scale` → output → 3.0
public static var oy_scale: CGFloat {
main.scale
}
/// `UIScreen.oy_isRetina` → output → false
public static var oy_isRetina: Bool {
main.responds(to: #selector(displayLink(withTarget: selector:))) && main.scale == 2.0
}
/// `UIScreen.oy_isRetinaHD` → output → true
public static var oy_isRetinaHD: Bool {
main.responds(to: #selector(displayLink(withTarget: selector:))) && main.scale == 3.0
}
/// `UIScreen.oy_screenBrightness` → output → 0.5
public static var oy_screenBrightness: CGFloat {
UIScreen.main.brightness
}
/// `UIScreen.oy_adjustBrightness(value: 0.5)`
public static func oy_adjustBrightness(value: CGFloat) {
UIScreen.main.brightness = value
}
}