I am currently trying to set the keyboard style globally, but my approach does not work.
I tried it using UIAppearance
and put this line of code inside the AppDelegate :
[[UITextField appearance] setKeyboardAppearance:UIKeyboardAppearanceAlert];
But what I got on the console is the following:
[UISearchBarTextField _UIAppearance_setKeyboardAppearance:]: unrecognized selector sent to instance 0xa1897e0
Any ideas how to solve this?
UIAppearance
only works with methods that are specifically marked with the macro UI_APPEARANCE_SELECTOR
to be compatible, and unfortunately keyboardAppearance
is not one of them.
The best way to get what you want is to subclass UITextField
and set keyboardAppearance = UIKeyboardAppearanceAlert;
in the the subclass's init
and initWithFrame:
methods. Then exclusively use your class wherever you would have used UITextField
in the app.