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?
Asked
Active
Viewed 1.7k times
44
Soner Gönül
- 94,086
- 102
- 195
- 339
Matt Winters
- 1,089
- 2
- 12
- 22
-
Possible duplicate of http://stackoverflow.com/questions/2694411/text-inset-for-uitextfield – titaniumdecoy Mar 08 '11 at 23:49
-
1@titaniumdecoy It's not. – Aleksejs Mjaliks Jan 15 '12 at 09:51
1 Answers
4
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);
}
Kenn Cal
- 3,609
- 2
- 16
- 18