UITextField实现左侧空出一定的边距
2017-08-15 本文已影响59人
6a948902fef0
就是通过uitextfield的leftview来实现的,同时要设置leftviewmode。
如果设置左右边距,需要再加上rightView功能
-(void)setTextFieldLeftPadding:(UITextField *)textField forWidth:(CGFloat)leftWidth
{
CGRect frame = textField.frame;
frame.size.width = leftWidth;
UIView *leftview = [[UIView alloc] initWithFrame:frame];
textField.leftViewMode = UITextFieldViewModeAlways;
textField.leftView = leftview;
}