File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,34 @@ class UIControlViewHelper {
55
55
alpha: CGFloat ( 1.0 )
56
56
)
57
57
}
58
+
59
+ //MARK: - padding
60
+ public enum padding {
61
+ case top
62
+ case bottom
63
+ }
64
+
65
+ //MARK: - getPadding(_ padding: padding)
66
+ static func getPadding( _ padding: padding ) -> CGFloat {
67
+ if #available( iOS 15 , * ) {
68
+ let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene
69
+ switch padding {
70
+ case . top:
71
+ return ( windowScene? . keyWindow? . safeAreaInsets. top) !
72
+ case . bottom:
73
+ return ( windowScene? . keyWindow? . safeAreaInsets. bottom) !
74
+ }
75
+ } else {
76
+ let window = UIApplication . shared. keyWindow
77
+ switch padding {
78
+ case . top:
79
+ return window? . safeAreaInsets. top ?? 0
80
+ case . bottom:
81
+ return window? . safeAreaInsets. bottom ?? 0
82
+ }
83
+ }
84
+ }
85
+
58
86
}
59
87
60
88
// MARK: - Detect gesture direction
You can’t perform that action at this time.
0 commit comments