[self.nameTextFieldaddTarget:selfaction:@selector(textField1TextDidBeginChange:)forControlEvents:UIControlEventEditingDidBegin];
- (void)textField1TextDidBeginChange:(UITextField*)nameFeild {
UIToolbar*toolBar =[UIToolbarnew];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem*doneBtn = [[UIBarButtonItemalloc]initWithTitle:@"完成" style:UIBarButtonItemStyleDonetarget:selfaction:@selector(numberFieldCancle)];
doneBtn.tintColor=[UIColorblueColor];
NSArray*items =@[flexSpace,doneBtn];
toolBar.items= items;
[toolBarsizeToFit];
nameFeild.inputAccessoryView= toolBar;
}
//收起键盘
- (void)numberFieldCancle{
[self.view resignFirstResponder];
[self.view endEditing:YES];
}
网友评论