@@ -12,7 +12,7 @@ import SimpleAlertLib
1212class ViewController : UIViewController {
1313
1414 override func viewDidAppear( _ animated: Bool ) {
15- self . view. backgroundColor = UIColor . orange
15+ self . view. backgroundColor = UIColor . gray
1616 showFirstAlert ( )
1717 for i in 1 ... 5 {
1818 showThirdAlert ( i)
@@ -31,34 +31,31 @@ class ViewController: UIViewController {
3131 alert. addButtonWithTitle ( " Another Alert, Dark " ) {
3232 self . showSecondAlert ( false )
3333 }
34-
35- alert. showInWindow ( self . view. window!)
36-
37-
34+ alert. show ( onComplete: { } , animated: true )
3835 }
3936
4037 func showSecondAlert( _ useLight: Bool ) {
4138
4239 let alert = SimpleAlert . makeAlert ( " Another Alert " , message: " You could fill out these boxes. " ) ;
43- let username = alert. addTextFieldWithPlaceholder ( " Username " , secureEntry: false , changeHandler: { ( textField) in
40+ let username = alert. addTextField ( with : " Username " , secureEntry: false , changeHandler: { ( textField) in
4441 print ( " typing! " )
4542 } )
46- alert. addTextFieldWithPlaceholder ( " Pass " , secureEntry: true , changeHandler: nil )
43+ alert. addTextField ( with : " Pass " , secureEntry: true , changeHandler: nil )
4744 alert. addButtonWithTitle ( " OK " , block: {
4845 print ( " Okay pressed, username is: \( username. text!) " )
4946 } )
5047 alert. addButtonWithTitle ( " Cancel " , block: { } )
5148 alert. theme = useLight ? . light : . dark
52- alert. showInWindow ( self . view. window!)
53-
49+ alert. show ( onComplete: {
50+ username. becomeFirstResponder ( )
51+ } , animated: true )
5452 }
5553
5654 func showThirdAlert( _ which: Int ) {
5755 let alert = SimpleAlert . makeAlert ( nil , message: " Many alerts: \( which) " ) ;
5856 alert. addButtonWithTitle ( " OK " , block: { } )
5957 alert. theme = . light
60- alert. showInWindow ( self . view. window!)
61-
58+ alert. show ( onComplete: { } , animated: true )
6259 }
6360
6461
0 commit comments