@@ -19,44 +19,69 @@ import UIKit
19
19
20
20
final class ActivationPointViewController : AccessibilityViewController {
21
21
22
- // MARK: - Private Properties
22
+ override func loadView( ) {
23
+ view = View ( )
24
+ }
23
25
24
- // A button for demonstrating what a standard activation point looks like.
25
- private let button : UIButton = . init( )
26
+ }
26
27
27
- private let customActivationPointView : CustomActivationPointView = . init ( )
28
+ // MARK: -
28
29
29
- private var views : [ UIView ] {
30
- return [
31
- button,
32
- customActivationPointView,
33
- ]
34
- }
30
+ private extension ActivationPointViewController {
35
31
36
- // MARK: - UIViewController
32
+ final class View : UIView {
37
33
38
- override func viewDidLoad( ) {
39
- super. viewDidLoad ( )
34
+ // MARK: - Life Cycle
40
35
41
- button . setTitle ( " Do Something " , for : . normal )
42
- button . setTitleColor ( . black , for : . normal )
36
+ override init ( frame : CGRect ) {
37
+ super . init ( frame : frame )
43
38
44
- views. forEach { view. addSubview ( $0) }
45
- }
39
+ button. setTitle ( " Do Something " , for: . normal)
40
+ button. setTitleColor ( . black, for: . normal)
41
+ addSubview ( button)
46
42
47
- override func viewDidLayoutSubviews ( ) {
48
- super . viewDidLayoutSubviews ( )
43
+ addSubview ( customActivationPointView )
44
+ }
49
45
50
- views. forEach { $0. frame. size = $0. sizeThatFits ( view. bounds. size) }
46
+ @available ( * , unavailable)
47
+ required init ? ( coder: NSCoder ) {
48
+ fatalError ( " init(coder:) has not been implemented " )
49
+ }
50
+
51
+ // MARK: - Private Properties
52
+
53
+ // A button for demonstrating what a standard activation point looks like.
54
+ private let button : UIButton = . init( )
51
55
52
- let statusBarHeight = UIApplication . shared . statusBarFrame . height
56
+ private let customActivationPointView : CustomActivationPointView = . init ( )
53
57
54
- var distributionSpecifiers : [ ViewDistributionSpecifying ] = [ statusBarHeight. fixed, 1 . flexible ]
55
- for subview in views {
56
- distributionSpecifiers. append ( subview)
57
- distributionSpecifiers. append ( 1 . flexible)
58
+ private var views : [ UIView ] {
59
+ return [
60
+ button,
61
+ customActivationPointView,
62
+ ]
58
63
}
59
- view. applySubviewDistribution ( distributionSpecifiers)
64
+
65
+ // MARK: - UIView
66
+
67
+ override func layoutSubviews( ) {
68
+ button. resize ( toFit: bounds. size)
69
+ customActivationPointView. resize ( toFit: bounds. size)
70
+
71
+ let statusBarHeight = window? . windowScene? . statusBarManager? . statusBarFrame. height ?? 0
72
+
73
+ applySubviewDistribution (
74
+ [
75
+ statusBarHeight. fixed,
76
+ 1 . flexible,
77
+ button,
78
+ 1 . flexible,
79
+ customActivationPointView,
80
+ 1 . flexible,
81
+ ]
82
+ )
83
+ }
84
+
60
85
}
61
86
62
87
}
0 commit comments