Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField Vertical Alignment

Is there a way to vertically align text in a UITextField half-way between UIControlContentVerticalAlignmentCenter and UIControlContentVerticalAlignmentBottom or do I have to go with one of those?

like image 403
Matt Winters Avatar asked Jul 16 '10 01:07

Matt Winters


1 Answers

You should subclass a UITextField, and override the following methods:

- (CGRect) textRectForBounds: (CGRect) bounds {   CGRect origValue = [super textRectForBounds: bounds];    /* Just a sample offset */   return CGRectOffset(origValue, 0.0f, 4.0f); }  - (CGRect) editingRectForBounds: (CGRect) bounds {   CGRect origValue = [super textRectForBounds: bounds];    /* Just a sample offset */         return CGRectOffset(origValue, 0.0f, 4.0f); } 
like image 178
Kenn Cal Avatar answered Oct 07 '22 18:10

Kenn Cal