44

UITextField途中でテキストを垂直方向に揃える方法はありますかUIControlContentVerticalAlignmentCenterUIControlContentVerticalAlignmentBottomまたはそれらのいずれかを使用する必要がありますか?

4

1 に答える 1

4

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-12-10T03:54:25.053 に答える