【问题标题】:UITextField Vertical AlignmentUITextField 垂直对齐
【发布时间】:2011-03-16 17:46:08
【问题描述】:

有没有办法在UITextField 的中间垂直对齐文本在UIControlContentVerticalAlignmentCenterUIControlContentVerticalAlignmentBottom 之间,还是我必须使用其中之一?

【问题讨论】:

标签: iphone vertical-alignment


【解决方案1】:

您应该继承一个 UITextField,并覆盖以下方法:

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

【讨论】:

    猜你喜欢
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 2012-04-29
    • 2015-09-06
    • 2015-01-16
    • 2011-10-03
    • 2013-07-03
    相关资源
    最近更新 更多