views:

428

answers:

4

I would like to inset the text of a UITextField. Is this possible? Thanks.

A: 

The best way is to inset your UITextField explicitly using the frame property.

Kenny
+3  A: 

In a class derived from UITextField, override at least this method:

- (CGRect)textRectForBounds:(CGRect)bounds;

It might be as simple as this if you have no additional content:

return CGRectInset( bounds , 10 , 10 );

UITextField provides several positioning methods you can override.

drawnonward
A: 

You can adjust the positioning of the text within a text field by making it a subclass of UITextField and overriding the -textRectForBounds: method.

Noah Witherspoon
+1  A: 

Overriding -textRectForBounds: will only change the inset of the placeholder text. To change the inset of the editable text, you need to also override -editingRectForBounds:.

azdev