初始化
@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;
###设置按键类型
textField.returnKeyType = UIReturnKeySearch;
###弹出键盘
[self.accountField becomeFirstResponder];
###回收键盘
[self.accountField resignFirstResponder];
self.view.endEditing(true)
###这里设置为无文字就灰色不可点
textField.enablesReturnKeyAutomatically = YES;
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
###时刻监听
UIControlEventEditingChanged
电话号码
https://github.com/iziz/libPhoneNumber-iOS
iOS强制使用系统键盘
https://blog.csdn.net/qq_18683985/article/details/81136805
限制UITextField手机号只能输入11位
https://blog.csdn.net/cloudywend0207/article/details/51017417
键盘类型-对应表
http://www.jianshu.com/p/9de5dab37eb4
UITextfield 总结
http://www.jianshu.com/p/f1014e4da859
https://www.cnblogs.com/yecong/p/6114061.html
iOS仿支付宝输入支付密码框
https://www.jianshu.com/p/41b449c53492
https://www.jianshu.com/p/7d6345219135
iOS 提示信息被键盘遮挡解决方案
https://blog.csdn.net/dlm_211314/article/details/52449693
placeholder 颜色
https://www.it610.com/article/1402000916713885696.htm
iOS12自动填充验证码 避免textField的UIControlEventEditingChanged方法走两次
https://www.jianshu.com/p/b64ca48a0a57