限制输入字数
pod ‘BNTextField-Limit’
UITextField *testField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
[testField limitCondition:^BOOL(NSString *inputStr){ return ![testField.text isEqualToString:@"111"]; } action:^{ NSLog(@"limit action"); }];
Or
[testField limitNums:3 action:^{ NSLog(@"num limit action"); }];
如果你想设置 textfield 代理,请在设置 limit 之前设置好。