프로그래밍/Swift(IOS & Mac)
로그인 창 만들기 .......2
낼은어떻게
2016. 1. 14. 18:37
UIAlertController 를 이용한 로그인 창 구현코드입니다.
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 | import UIKit class ViewController: UIViewController { @IBAction func bTnLogPw(sender: AnyObject) { let alert = UIAlertController(title: "입력", message: "로그인 정보를 입력합니다.", preferredStyle: .Alert) alert.addTextFieldWithConfigurationHandler( ){ (textField) in textField.placeholder = "Login ID" } alert.addTextFieldWithConfigurationHandler( ){ (textField) in textField.placeholder = "Password" textField.secureTextEntry = true } let cancelAction = UIAlertAction(title: "취소", style: .Cancel, handler: nil) let okAction = UIAlertAction(title: "확인", style: .Default ){ (_) in let logid = alert.textFields?[0].text let pw = alert.textFields?[1].text if logid == "1111" && pw == "2222" { } else { } } alert.addAction(cancelAction) alert.addAction(okAction) self.presentViewController(alert, animated: false, completion: nil) } } | cs |