ma11hew28
ma11hew28

Reputation: 126507

UITextField: textRectForBounds: Vs. editingRectForBounds:

What's the difference between a UITextField's rectangle for its text vs. editable text?

I just want to move where the text is displayed inside the text field. Should I just override both methods with the same exact implementation?

UITextField Class Reference

textRectForBounds:

Returns the drawing rectangle for the text field’s text.

editingRectForBounds:

Returns the rectangle in which editable text can be displayed.

Upvotes: 9

Views: 7251

Answers (1)

ma11hew28
ma11hew28

Reputation: 126507

textRectForBounds: lets you set the rectangle for the text when the text field is not being edited.

editingRectForBounds: lets you set the rectangle for the text when the text field is being edited.

So, yes, you should implement both with the same exact implementation unless you want the text to jump when you begin & end editing.

Upvotes: 28

Related Questions