Reputation: 20975
Changing the
NSDictionary * barButtonAppearanceDict = @{UITextAttributeFont : font};
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict forState:UIControlStateNormal];
Doesn't affect the UIBarButtonItem when using plain...
How can i change the font for the plain style UIBarButtonItem
This still applies to iOS6
Upvotes: 1
Views: 2440
Reputation: 73
I set the following in the appdelegate and it worked great:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"Avenir" size:21.0]} forState:UIControlStateNormal];
}
Upvotes: 0
Reputation: 1616
This works for me however (with plain BarButtonItem), have just tested it:
[self.myBarButtonItem setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica" size:22.0],NSFontAttributeName,
nil]forState:UIControlStateNormal];
For using Appearance proxy you can try this:
NSDictionary *attrDict = [NSDictionary dictionaryWithObject: [UIFont fontWithName:@"Helvetica" size:22.0] forKey: UITextAttributeFont];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
forState: UIControlStateDisabled];
[[UIBarButtonItem appearance] setTitleTextAttributes: attrDict
forState: UIControlStateNormal];
Are you sure, that you implement this in your AppDelegate
- class? (e.g. in didFinishLaunchingWithOptions
-method)
Upvotes: 1