44

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?

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Matt Winters
  • 1,099
  • 2
  • 12
  • 22

1 Answers1

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,659
  • 2
  • 17
  • 18