textField设置文字距离左边的间隙

2017-04-16  本文已影响94人  T_Choues

1、设置padding

[textField setValue:@(5) forKey:@"paddingTop"];

[textField setValue:@(5) forKey:@"paddingLeft"];

[textField setValue:@(5) forKey:@"paddingBottom"];

[textField setValue:@(5) forKey:@"paddingRight"];

2、设置leftView

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, CGRectGetHeight(textField.frame))];

textField.leftView = view;

textField.leftViewMode = UITextFieldViewModeAlways;

上一篇下一篇

猜你喜欢

热点阅读