iOS UITextField 小写字母自动显示大写

iOS UITextField 小写字母自动显示大写_第1张图片

、、、

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

{

if ([FunctionClass IsBlankString:string])

{

return YES;

}

char commitChar = [string characterAtIndex:0];

if (commitChar > 96 && commitChar < 123)

{

//小写变成大写

NSString * uppercaseString = string.uppercaseString;

NSString * str1 = [textField.text substringToIndex:range.location];

NSString * str2 = [textField.text substringFromIndex:range.location];

textField.text = [NSString stringWithFormat:@"%@%@%@",str1,uppercaseString,str2];

return NO;

}

return YES;

}


、、、

你可能感兴趣的:(iOS UITextField 小写字母自动显示大写)