1.设置清空符号
self.inputName.clearButtonMode = UITextFieldViewModeAlways;
self.inputName == UITextField
2.编辑返回键
// 需要签订
并且设置代理人的属性
#define HEIGHT self.view.frame.size.height
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
3.设置在编辑文本时让输入框上下移动,不让键盘挡住输入框
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
if (textField.frame.origin.y > HEIGHT / 2) {
CGFloat height = textField.frame.origin.y - HEIGHT / 2;
self.view.center = CGPointMake(self.view.center.x, self.view.center.y - height);
}
return YES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
if (textField.frame.origin.y > HEIGHT / 2) {
CGFloat height = textField.frame.origin.y - HEIGHT / 2;
self.view.center = CGPointMake(self.view.center.x, self.view.center.y + height);
}
return YES;
}
4.安全输入
用textField.secureTextEntry = YES
// 表示安全输入