Reputation: 9040
It seems like the iOS 11 appearance proxy mechanism for setting UIBarButtonItem font is not working completely. (It behaves as expected in iOS 10).
I want to know if this is a bug, or there is somehow a different way to do this.
My code:
NSDictionary *barButtonAppearanceDict = @{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Light" size:24], NSForegroundColorAttributeName: [UIColor purpleColor]};
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict forState:UIControlStateNormal];
Basically, the code appears to work, the button font is styled appropriately. However, when the user taps the button, the style reverts while the button is pressed.
Here's a video:
https://www.dropbox.com/s/hqgpbnlq6gw884p/UIBarButtonItem%20Interaction.mov?dl=0
To repro, create a new app using the Master-Detail app template. Add code snippet above in:
didFinishLaunchingWithOptions
Upvotes: 0
Views: 122
Reputation: 90
You forget to set theHighlighted
style.
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict UIControlStateHighlighted];
Upvotes: 2