-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if (range.location == textField.text.length && [string isEqualToString:@" "]) {
// ignore replacement string and add your own
textField.text = [textField.text stringByAppendingString:@"\u00a0"];
return NO;
}
// for all other cases, proceed with replacement
return YES;
}
//nameField(UITextfield) 最后去文本数据的时候执行下面的操作
nameField.text = [nameField.text stringByReplacingOccurrencesOfString:@"\u00a0" withString:@" "];
IOS UITextfield设置右对齐后 开头空格无法右对齐的解决方式
最新推荐文章于 2022-11-15 12:41:40 发布