Reputation: 3042
UITextView indentation problem:
For example, I want the "test" text a little bit right, what property should I set?
Upvotes: 5
Views: 4218
Reputation: 11217
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);
Upvotes: 1
Reputation: 1965
Try this
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
self.yourtextField.leftView = paddingView;
self.yourtextField.leftViewMode = UITextFieldViewModeAlways;
Upvotes: 12
Reputation: 38728
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);
}
Upvotes: 8