5

For example, I want the "test" text a little bit right, what property should I set?

UITextView indentation problem:

For example, I want the "test" text a little bit right, what property should I set?

Ben Lu
  • 2,982
  • 4
  • 31
  • 54

3 Answers3

12

Try this

    UIView *paddingView           = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
    self.yourtextField.leftView             = paddingView;
    self.yourtextField.leftViewMode         = UITextFieldViewModeAlways;
Piyush Kashyap
  • 1,965
  • 1
  • 14
  • 16
8

Create a subclass and override textRectForBounds: and editingRectForBounds:. Your new implementations may look something like

- (CGRect)textRectForBounds:(CGRect)bounds;
{
    return CGRectInset([super textRectForBounds:bounds], 10.f, 0.f);
}

- (CGRect)editingRectForBounds:(CGRect)bounds;
{
    return CGRectInset([super editingRectForBounds:bounds], 10.f, 0.f);
}
Paul.s
  • 38,494
  • 5
  • 70
  • 88
1

Just try like this simple method....

textfield.frame = CGRectMake(textfield.frame.origin.x+10, textfield.frame.origin.y, textfield.frame.size.width, textfield.frame.size.height);
Rajesh Loganathan
  • 11,129
  • 4
  • 78
  • 90