The default height of a UITextField
with border style UITextBorderStyleRoundedRect
is 31px. For an iPad App, I'd like to make a UITextField with a height of 60px and position the text vertically centered so that it looks good (by default the text is drawn only a few pixel below the top border of the UITextField).
If i do the following...
UITextField *txtLogin = [[UITextField alloc] initWithFrame:CGRectMake(200,200,300,60)];
txtLogin.borderStyle = UITextBorderStyleRoundedRect;
...the result looks like this: http://grab.by/6jRc
As you can see, the input text is not vertically centered. I tried to find a solution and found out that I just have to inherit my own custom class from UITextField and override the - (CGRect)textRectForBounds:(CGRect)bounds
method.
However, this method is never called and according to this link there is a bug in Apple's API. Therefore I'm looking for alternatives that work.
What would be a good solution to solve this problem and achieve correct vertical alignment for input text?
[txtLogin setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With