Created
January 14, 2017 17:29
-
-
Save mikru1688/eb6bc94f6049398a7c38080f05e59d5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.view.backgroundColor = UIColor.white | |
// 身份證號 | |
let idLbl: UILabel = UILabel() | |
idLbl.frame = CGRect(x: 0, y: 40, width: self.view.frame.size.width / 3, height: 50) | |
idLbl.font = UIFont.systemFont(ofSize: 20) | |
idLbl.textColor = UIColor.black | |
idLbl.textAlignment = NSTextAlignment.left | |
idLbl.adjustsFontSizeToFitWidth = true | |
idLbl.text = "\t" + "身份證號:" | |
self.view.addSubview(idLbl) | |
// 身份證輸入框 | |
let idTxtFld: UITextField = UITextField() | |
idTxtFld.frame = CGRect(x: idLbl.frame.origin.x + idLbl.frame.size.width, y: 40, width: self.view.frame.size.width / 3 * 2, height: 50) | |
idTxtFld.font = UIFont.systemFont(ofSize: 20) | |
idTxtFld.backgroundColor = UIColor.clear | |
idTxtFld.textAlignment = NSTextAlignment.left | |
idTxtFld.clearButtonMode = UITextFieldViewMode.unlessEditing // 清除按鈕 | |
idTxtFld.placeholder = "請輸入證件號碼" | |
idTxtFld.delegate = self | |
self.view.addSubview(idTxtFld) | |
// 註冊tab事件,點選瑩幕任一處可關閉瑩幕小鍵盤 | |
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.dismissKeyboard)) | |
self.view.addGestureRecognizer(tap) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment