iOS UITextField设置起始字符开始位置

1.通过设置一个”左视图”

CGRect frame = self.accountTF.frame;
frame.size.width = 8;// 距离左侧的距离
UIView *leftview = [[UIView alloc] initWithFrame:frame];
self.accountTF.leftViewMode = UITextFieldViewModeAlways;

2.设置paddingleft

[self.accountTF setValue:[NSNumber numberWithInt:10] forKey:@"paddingLeft"];

使用2这种方式, 输入内容起始位置会右移10, 占位字符起始位置不会变.

猜你喜欢

转载自blog.csdn.net/dongzhensong/article/details/80567896