0

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

1
  • 1
    Cool! Can you provide enough info so we can reproduce / test? Commented Apr 12, 2018 at 19:41

1 Answer 1

2

You forget to set theHighlighted style.

[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict UIControlStateHighlighted];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.