importUIKit
classViewController:UIViewController{
/*用戶界面:
1月弛、鍵盤能夠回收爱咬,提示點(diǎn)擊按鈕的時候鍵盤能回收,核心代碼:[輸入框:resignFirstResponder]
2、密碼和確認(rèn)密碼設(shè)置密文輸入
3、手機(jī)號使用數(shù)字鍵盤
*/
overridefuncviewDidLoad() {
super.viewDidLoad()
letlabel =UILabel(frame:CGRectMake(30,60,60,20))
view.addSubview(label)
label.text="用戶名"
label.textColor=UIColor.blackColor()
label.textAlignment= .Left
label.font=UIFont.systemFontOfSize(15)
lettextField =UITextField(frame:CGRectMake(100,60,200,20))
view.addSubview(textField)
textField.placeholder="用戶名"
textField.borderStyle= .RoundedRect
textField.returnKeyType= .Go
textField.delegate=self
letlabel1 =UILabel(frame:CGRectMake(30,100,60,20))
view.addSubview(label1)
label1.text="密碼"
label1.textColor=UIColor.blackColor()
label1.textAlignment= .Left
label1.font=UIFont.systemFontOfSize(15)
lettextField1 =UITextField(frame:CGRectMake(100,100,200,20))
view.addSubview(textField1)
textField1.placeholder="密碼"
textField1.secureTextEntry=true
textField1.borderStyle= .RoundedRect
textField1.returnKeyType= .Go
textField1.delegate=self
letlabel2 =UILabel(frame:CGRectMake(30,140,60,20))
view.addSubview(label2)
label2.text="確認(rèn)密碼"
label2.textColor=UIColor.blackColor()
label2.textAlignment= .Left
label2.font=UIFont.systemFontOfSize(15)
lettextField2 =UITextField(frame:CGRectMake(100,140,200,20))
view.addSubview(textField2)
textField2.placeholder="確認(rèn)密碼"
textField2.secureTextEntry=true
textField2.borderStyle= .RoundedRect
textField2.returnKeyType= .Go
textField2.delegate=self
letlabel3 =UILabel(frame:CGRectMake(30,180,60,20))
view.addSubview(label3)
label3.text="手機(jī)號"
label3.textColor=UIColor.blackColor()
label3.textAlignment= .Left
label3.font=UIFont.systemFontOfSize(15)
lettextField3 =UITextField(frame:CGRectMake(100,180,200,20))
view.addSubview(textField3)
textField3.placeholder="手機(jī)號"
textField3.keyboardType= .NumberPad
textField3.borderStyle= .RoundedRect
textField3.returnKeyType= .Go
textField3.delegate=self
letlabel4 =UILabel(frame:CGRectMake(30,220,60,20))
view.addSubview(label4)
label4.text="郵箱"
label4.textColor=UIColor.blackColor()
label4.textAlignment= .Left
label4.font=UIFont.systemFontOfSize(15)
lettextField4 =UITextField(frame:CGRectMake(100,220,200,20))
view.addSubview(textField4)
textField4.placeholder="郵箱"
textField4.keyboardType= .EmailAddress
textField4.borderStyle= .RoundedRect
textField4.returnKeyType= .Go
textField4.delegate=self
}
overridefuncdidReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
extensionViewController:UITextFieldDelegate{
//實(shí)現(xiàn)點(diǎn)擊return鍵響應(yīng)的方法
functextFieldShouldReturn(textField:UITextField) ->Bool{
//使鍵盤回收淌哟,所以取消輸入框的第一響應(yīng)者
textField.resignFirstResponder()
returntrue
}
}