Is there a useful property in a cocoa-touch project that would allow setting the one-and-only consistent style of keyboard appearance throughout the app? Say I want UIKeyboardAppearanceAlert
on all the textFields and textViews I have in my app without directly modifying anything. Is is possible?

- 11,995
- 20
- 81
- 120
1 Answers
No, it isn't possible. The keyboardAppearance
is part of the UITextInputTraits
protocol and is not marked as a UIAppearance method. If it was you could do something like:
[[UITextField appearance] setKeyboardAppearance:UIKeyboardAppearanceAlert];
You can identify methods that can be used with the appearance proxy by looking at the docs or, from within your code, at the UIKit headers (command-click on a method and it will take you to the header.
For example, in UINavigationBar.h, you can see this:
@property(nonatomic,retain) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR; // default is nil
The marker UI_APPEARANCE_SELECTOR means that this property can be used on the appearance proxy. It isn't present on keyboardAppearance
, and it doesn't look like any keys in the info.plist allow you to define an application-wide appearance.
Your best bet is to subclass textfield and textview and use those subclasses everywhere.

- 118,105
- 32
- 252
- 268
-
9Actually on iOS7 if you call `[[UITextField appearance] setKeyboardAppearance:UIKeyboardAppearanceDark];` it works, even if the property has no UI_APPEARANCE_SELECTOR decorator – Luca Bernardi Oct 28 '13 at 16:18
-
4Luca's code worked for me with UITextField, but my app crashed when I tried to do the same thing with UITextView. – arlomedia Jun 18 '14 at 20:15