UITextField實現左側空出必定的邊距

就是經過uitextfield的leftview來實現的,同時要設置leftviewmode。ui

若是設置左右邊距,須要再加上rightView功能spa

 

-(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;
}
相關文章
相關標籤/搜索