有没有办法在UITextField
和UIControlContentVerticalAlignmentCenter
之间的UIControlContentVerticalAlignmentBottom
中间垂直对齐文字,还是我必须选择其中一个?
答案 0 :(得分: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);
}