Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placeholder text misaligned in UITextField of UISearchBar

I'm trying to customize UISearchBar's font through appearance proxy. It works, but somehow, the placeholder text is not centered vertically. I tried to set the vertical alignment property; the placeholder text would get centred but text entered would be slightly below the center line... Is there any way to fix this?

Edit: Code I used to add custom font:

[[UITextField appearanceWhenContainedIn: [UISearchBar class], nil]
                                setFont: [UIFont customFontWithSize: 17]];

placeholder text

normal text

like image 932
SChang Avatar asked Apr 11 '13 03:04

SChang


1 Answers

Whenever this happens to me, it is usually caused by some modification to UIAppearance not blending well with UISearchBar. Look at any previous hacks you may have made and perhaps try commenting them out one at a time.

In my particular case it was actually a modification to NSForegroundColor in a text attribute, so this misalignment may be unrelated to your font change.

like image 100
danielmhanover Avatar answered Nov 17 '22 01:11

danielmhanover