textField1 = UITextField()
//在編輯框左側(cè)設(shè)置圖片
textField1.leftView = UIImageView(image: UIImage(named: "lock.png"))
textField1.leftViewMode = .Always
textField1.backgroundColor = UIColor.whiteColor()
//在編輯框上設(shè)置提示
textField1.placeholder = "原密碼"
textField1.layer.cornerRadius = 10
textField1.layer.borderColor = UIColor(red: 0.180392, green: 0.603922, blue: 0.909804, alpha: 1).CGColor
textField1.layer.borderWidth = 1
textField1.delegate = self
//當(dāng)點(diǎn)擊編輯框時(shí)清空里面的內(nèi)容
textField1.clearsOnBeginEditing = true
//編輯框末端添加刪除按鈕
textField1.clearButtonMode = .WhileEditing
//設(shè)置為密碼模式
textField3.secureTextEntry = true
self.view.addSubview(textField1)
實(shí)時(shí)打印編輯框里面輸入的東西
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
//ts就是在編輯框里面輸入的東西
let os: NSString = textField.text!
let ts = os.stringByReplacingCharactersInRange(range, withString: string)
}
[textField addTarget:self action:@selector(notification_a:) forControlEvents:UIControlEventEditingChanged];
- (void)notification_a:(UITextField*)textField{
NSLog(@"%@",textField.text);
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。