初始化
@property (nonatomic, strong) UITextField *tfName;
- (UITextField *)tfName {
if (!_tfName) {
UITextField *textField = [[UITextField alloc] init];
textField.font = systemFont(15);
textField.placeholder = @"請輸入自定義項目";
textField.textColor = darkTextColor;
textField.backgroundColor = rgb(238,238,238);
_tfName = textField;
}
return _tfName;
}
方法
###修改光標顏色
textField.tintColor = UIColor.mj_appColor;
###設(shè)置按鍵類型
textField.returnKeyType = UIReturnKeySearch;
###彈出鍵盤
[self.accountField becomeFirstResponder];
###回收鍵盤
[self.accountField resignFirstResponder];
self.view.endEditing(true)
###這里設(shè)置為無文字就灰色不可點
textField.enablesReturnKeyAutomatically = YES;
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
###時刻監(jiān)聽
UIControlEventEditingChanged
電話號碼
https://github.com/iziz/libPhoneNumber-iOS
iOS強制使用系統(tǒng)鍵盤
https://blog.csdn.net/qq_18683985/article/details/81136805
限制UITextField手機號只能輸入11位
https://blog.csdn.net/cloudywend0207/article/details/51017417
鍵盤類型-對應表
http://www.reibang.com/p/9de5dab37eb4
UITextfield 總結(jié)
http://www.reibang.com/p/f1014e4da859
https://www.cnblogs.com/yecong/p/6114061.html
iOS仿支付寶輸入支付密碼框
http://www.reibang.com/p/41b449c53492
http://www.reibang.com/p/7d6345219135
iOS 提示信息被鍵盤遮擋解決方案
https://blog.csdn.net/dlm_211314/article/details/52449693
placeholder 顏色
https://www.it610.com/article/1402000916713885696.htm
iOS12自動填充驗證碼 避免textField的UIControlEventEditingChanged方法走兩次
http://www.reibang.com/p/b64ca48a0a57