中英文限制字数

    [_panel setShouldChangeCharactersInRange:^(UITextField *textField,NSRange range,NSString *string){
        NSString *topic = [textField.text stringByReplacingCharactersInRange:range withString:string];
        if([topic length] < [textField.text length]) {
            return YES;
        }
        if (topic.length > kMaxTopicLength) {
            return NO;
        }
        return YES;
    }];

你可能感兴趣的:(中英文限制字数)