Want to add text inset for UITextField in IOS? You can set text inset for UITextField by setting the leftView. 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
:
1 2 3 4 5 6 7 8 9 | // placeholder position - (CGRect)textRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 10, 10); } // text position - (CGRect)editingRectForBounds:(CGRect)bounds { return CGRectInset(bounds, 10, 10); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.