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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With