Setting tintColor using the appearance API does not respect the hierarchy

Originator:a.cecilia.luque
Number:rdar://34303797 Date Originated:September 7 2017, 5:04 PM
Status:Closed Resolved:
Product:UIKit Product Version:
Classification: Reproducible:Always
 
Summary: 
Customising the appearance of barButtonsItems using the appearance API does not work properly, the tintColor selection does not respect the hierarchy.

The issue is related with this code:
UIView.appearance().tintColor = .red
UINavigationBar.appearance().tintColor = .green

Steps to Reproduce:
Open attached project.
- Compiling with xCode8 and running on iPhone5S device with iOS11Beta10, my barButtonItems are green. OK.
- Compiling with xCode9Beta6 and running on iPhone5S device with iOS11Beta10, my barButtonItems are red. NOT OK.

Related information: https://stackoverflow.com/questions/45893605/changing-the-tint-colour-of-elements-in-uinavigationbar-ios-11/46092016#46092016

Comments

Engineering has provided the following information regarding this issue: tintColor is not supported when used with the appearance proxy. The note from Appearance.h: “Note for iOS7: On iOS7 the tintColor property has moved to UIView, and now has special inherited behavior described in UIView.h. This inherited behavior can conflict with the appearance proxy, and therefore tintColor is now disallowed with the appearance proxy.” The behavior of using tintColor with the appearance proxy is therefore undefined and not supported. UIBarButtonItem does have a tintColor property that is supported with the appearance proxy, so if you want to customize the tintColor of bar button items seperately from the bar, that is an acceptable way to do this.

By a.cecilia.luque at Sept. 20, 2017, 7:40 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!