Mat*_*ers 44 iphone vertical-alignment
有没有办法在UITextField中途之间垂直对齐文本UIControlContentVerticalAlignmentCenter,UIControlContentVerticalAlignmentBottom或者我是否必须使用其中一种?
您应该子类化 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);
}
Run Code Online (Sandbox Code Playgroud)