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
您忘记设置Highlighted
样式。
[[UIBarButtonItem appearance] setTitleTextAttributes:barButtonAppearanceDict UIControlStateHighlighted];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.