UITextField清除按钮的模式、关闭自动纠错单词、关闭自动首字母大写、数字键盘上加一个完成按钮

清除按钮的模式:clearButtonMode

关闭自动纠错单词的功能:[_textField setAutocorrectionType:UITextAutocorrectionTypeNo];

关闭首字母自动大写功能:[_textField setAutocapitalizationType:UITextAutocapitalizationTypeNone];

想让数字键盘跳下去可在键盘上加一个完成按钮的toolbar:

UIToolbar* numberToolBar= [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
numberToolBar.items = [NSArray arrayWithObjects:
                      [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleBordered target:nil action:nil],
                      [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                      [[UIBarButtonItem alloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
                      nil];
numberToolBar.tintColor=COLOR_FOR_APP;
_textField.inputAccessoryView=numberToolBar;

 
  

//点击toolBar上的完成触发事件

- (void)doneWithNumberPad
{
    if (_textField isFirstResponder){
        [_textField resignFirstResponder];
    }
}



你可能感兴趣的:(iOS)