UIButton overwrites UIBarButtonItem tint color in UINavigationBar

Originator:spindel.daniel97
Number:rdar://34204150 Date Originated:01/09/2017
Status:Closed Resolved:
Product:UIKit Product Version:Xcode Version 9.0 beta 6 (9M214v), iOS 11.0 (15A5370a)
Classification:Bug Reproducible:Always
 
Area:
UIKit

Summary:
I have been using `UINavigationBar.appearance().tintColor` to change the tint color of the buttons in the `UINavigationBar`. Until iOS 10.3.1, it was working perfectly. With Xcode 9 and iOS 11 this solution is no longer working. It seems like `UIButton` overwrites the tint color setting of `UINavigationBar`.


Steps to Reproduce:
1. Create a new project with a Single View, embed that view into a Navigation Controller
2. Add a Bar Button Item to the Navigation Bar
3. In the ViewController, add these lines to the `viewDidLoad` method:
    UINavigationBar.appearance().tintColor = UIColor.red
    UIButton.appearance().tintColor = UIColor.blue
4. Run the app. The button in the Navigation Bar will be blue.
5. Remove the second line (starting with `UIButton`)
6. Run the app again. The button is now red.


Expected Results: The tint color of `UIBarButtonItem` changes with `UINavigationBar.appearance().tintColor` and `UIButton.appearance().tintColor` doesn't change its tint color.


Actual Results: The tint color of `UIBarButtonItem` is inherited from `UIButton.appearance().tintColor`instead of `UINavigationBar.appearance().tintColor`


Version/Build: Xcode Version 9.0 beta 6 (9M214v), iOS 11.0 (15A5370a)


Additional information:
Attached screenshots where you can see that `_UIButtonBarButton` has the tint color of `UINavigationBar`, but `_UIModernBarButton` has the tint color of `UIButton`. I've also attached a test project where I was able to reproduce the issue. Here's a question regarding this issue on StackOverflow: https://stackoverflow.com/questions/45893605/changing-the-tint-colour-of-elements-in-uinavigationbar-ios-11

Comments

Engineering has provided the following feedback regarding this issue:

UIView.tintColor is not an appearance selector, and specifically is documented as not working correctly as an appearance property due to its inheritance properties.

By spindel.daniel97 at Sept. 18, 2017, 7:11 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!