textField1 = UITextField()
//在編輯框左側設置圖片
textField1.leftView = UIImageView(image: UIImage(named: "lock.png"))
textField1.leftViewMode = .Always
textField1.backgroundColor = UIColor.whiteColor()
//在編輯框上設置提示
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
//當點擊編輯框時清空里面的內容
textField1.clearsOnBeginEditing = true
//編輯框末端添加刪除按鈕
textField1.clearButtonMode = .WhileEditing
//設置為密碼模式
textField3.secureTextEntry = true
self.view.addSubview(textField1)
實時打印編輯框里面輸入的東西
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);
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。