开发者

UITextField Vertical Alignment

开发者 https://www.devze.com 2023-01-07 18:55 出处:网络
Is there a way to vertically align text in a UITextField half-way between UIControlContentVerticalAlignmentCenter and UIControlContentVerticalAlignmentBottom or do I have to go w开发者_开发问答ith one

Is there a way to vertically align text in a UITextField half-way between UIControlContentVerticalAlignmentCenter and UIControlContentVerticalAlignmentBottom or do I have to go w开发者_开发问答ith one of those?


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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消