Setting a tint color for a SF Symbol or System Item using Navigation Controller's UIAppearance API

Hi,

I'm working on a View Controller where the Navigation Controller's UIBarButtonItems, composed of SF Symbol images and/or System Items, should change their tint color based on the current Navigation Controller scroll edge or default appearance.

let buttonAppearance: UIBarButtonItemAppearance = .init(style: .plain)
buttonAppearance.normal.titleTextAttributes = [.foregroundColor: color]
standardAppearance.buttonAppearance = buttonAppearance

I've used UIBarButtonItemAppearance titleTextAttributes to successfully change a UIButton's label text color, but I wasn't able to find a supported method under the UIAppearance API to do the same update to images.

I'd highly appreciate clarification on whether or not it is supported and, if not, what could be some alternatives.

Specs: iOS 16+

Thanks!

Answered by Frameworks Engineer in 774997022

Unfortunately there isn't a good means of doing this – the only thing that fully supports what you're trying to do is the navigation bar's tint color itself, which isn't part of the appearance API.

Accepted Answer

Unfortunately there isn't a good means of doing this – the only thing that fully supports what you're trying to do is the navigation bar's tint color itself, which isn't part of the appearance API.

Setting a tint color for a SF Symbol or System Item using Navigation Controller's UIAppearance API
 
 
Q