How to install UIKeyboard-Style for the whole application?

I am currently trying to establish a keyboard style everywhere, but my approach does not work. I tried this with UIAppearance and put this line of code in 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?

+4
source share
2 answers

UIAppearance only works with methods specifically allocated by the UI_APPEARANCE_SELECTOR macro for compatibility, and, unfortunately, keyboardAppearance not one of them.

The best way to get what you want is to subclass UITextField and set keyboardAppearance = UIKeyboardAppearanceAlert; in subclasses of init and initWithFrame: Then use your class exclusively wherever you use UITextField in the application.

+2
source

iOS7 extended the UIAppearance protocol for UITextFields, ergo you can now set the Appearance keyboard to UITextField.

 [UITextField appearance].keyboardAppearance = UIKeyboardAppearanceDark; 

However, UITextView does not support it. For this class, I would go with jszumski solution

+7
source

All Articles