@@ -50,10 +50,18 @@ class ViewController: UIViewController {
50
50
return button
51
51
} ( )
52
52
53
- lazy var statusBarButton : UIButton = { [ unowned self] in
53
+ lazy var showWhistleButton : UIButton = { [ unowned self] in
54
54
let button = UIButton ( )
55
- button. addTarget ( self , action: #selector( statusBarButtonDidPress ( _: ) ) , forControlEvents: . TouchUpInside)
56
- button. setTitle ( " Status bar " , forState: . Normal)
55
+ button. addTarget ( self , action: #selector( showWhistleButtonDidPress ( _: ) ) , forControlEvents: . TouchUpInside)
56
+ button. setTitle ( " Show Whistle " , forState: . Normal)
57
+
58
+ return button
59
+ } ( )
60
+
61
+ lazy var presentWhistleButton : UIButton = { [ unowned self] in
62
+ let button = UIButton ( )
63
+ button. addTarget ( self , action: #selector( presentWhistleButtonDidPress ( _: ) ) , forControlEvents: . TouchUpInside)
64
+ button. setTitle ( " Present permanent Whistle " , forState: . Normal)
57
65
58
66
return button
59
67
} ( )
@@ -84,13 +92,15 @@ class ViewController: UIViewController {
84
92
85
93
view. addSubview ( scrollView)
86
94
[ titleLabel, presentButton, showButton,
87
- presentPermanentButton, notificationButton, statusBarButton] . forEach { scrollView. addSubview ( $0) }
88
-
89
- [ presentButton, showButton, presentPermanentButton, notificationButton, statusBarButton] . forEach {
90
- $0. setTitleColor ( UIColor . grayColor ( ) , forState: . Normal)
91
- $0. layer. borderColor = UIColor . grayColor ( ) . CGColor
92
- $0. layer. borderWidth = 1.5
93
- $0. layer. cornerRadius = 7.5
95
+ presentPermanentButton, notificationButton,
96
+ showWhistleButton, presentWhistleButton] . forEach { scrollView. addSubview ( $0) }
97
+
98
+ [ presentButton, showButton, presentPermanentButton,
99
+ notificationButton, showWhistleButton, presentWhistleButton] . forEach {
100
+ $0. setTitleColor ( UIColor . grayColor ( ) , forState: . Normal)
101
+ $0. layer. borderColor = UIColor . grayColor ( ) . CGColor
102
+ $0. layer. borderWidth = 1.5
103
+ $0. layer. cornerRadius = 7.5
94
104
}
95
105
96
106
guard let navigationController = navigationController else { return }
@@ -150,13 +160,21 @@ class ViewController: UIViewController {
150
160
navigationController? . pushViewController ( controller, animated: true )
151
161
}
152
162
153
- func statusBarButtonDidPress ( button: UIButton ) {
163
+ func showWhistleButtonDidPress ( button: UIButton ) {
154
164
let murmur = Murmur ( title: " This is a small whistle... " ,
155
165
backgroundColor: UIColor ( red: 0.975 , green: 0.975 , blue: 0.975 , alpha: 1 ) )
156
166
157
167
Whistle ( murmur)
158
168
}
159
169
170
+ func presentWhistleButtonDidPress( button: UIButton ) {
171
+ let murmur = Murmur ( title: " This is a permanent whistle... " ,
172
+ backgroundColor: UIColor . redColor ( ) ,
173
+ titleColor: UIColor . whiteColor ( ) )
174
+
175
+ Whistle ( murmur, action: . Present)
176
+ }
177
+
160
178
// MARK - Configuration
161
179
162
180
func setupFrames( ) {
@@ -168,9 +186,10 @@ class ViewController: UIViewController {
168
186
showButton. frame = CGRect ( x: 50 , y: presentButton. frame. maxY + 15 , width: totalSize. width - 100 , height: 50 )
169
187
presentPermanentButton. frame = CGRect ( x: 50 , y: showButton. frame. maxY + 15 , width: totalSize. width - 100 , height: 50 )
170
188
notificationButton. frame = CGRect ( x: 50 , y: presentPermanentButton. frame. maxY + 15 , width: totalSize. width - 100 , height: 50 )
171
- statusBarButton. frame = CGRect ( x: 50 , y: notificationButton. frame. maxY + 15 , width: totalSize. width - 100 , height: 50 )
189
+ showWhistleButton. frame = CGRect ( x: 50 , y: notificationButton. frame. maxY + 15 , width: totalSize. width - 100 , height: 50 )
190
+ presentWhistleButton. frame = CGRect ( x: 50 , y: showWhistleButton. frame. maxY + 15 , width: totalSize. width - 100 , height: 50 )
172
191
173
- let height = statusBarButton . frame. maxY >= totalSize. height ? statusBarButton . frame. maxY + 35 : totalSize. height
192
+ let height = presentWhistleButton . frame. maxY >= totalSize. height ? presentWhistleButton . frame. maxY + 35 : totalSize. height
174
193
scrollView. contentSize = CGSize ( width: totalSize. width, height: height)
175
194
}
176
195
}
0 commit comments