How can I change the font size of UISearchBar ?
How can I change the font size of UISearchBar ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The UISearchBar has a UITextField inside, but there’s no property to access it. So, there is no way for doing it in a standard way.
But there is a non-stardard way to workaround it.
UISearchBar inherits from UIView, you can access it’s subviews using [searchBar subviews].
If you print in the console it’s subviews you will see that it have these views.
UISearchBarBackground, UISearchBarTextField.
So, to change the font size you will only need to do that
But, if the UISearchBar changes in the future and the textfield isn’t in the position 1 anymore, your program will crash, so it’s better to check through the subviews the position of the UITextField and then set the font size.