Reputation: 18765
Setting the appearance of a UINavigationBar
title, background, etc. based on whether it is showing large or normal is no problem. But how to update the appearance / tint color of the bar button items accordingly?
Have a code at the following appearance and the code that I used to create it:
UIBarButtonItem.appearance(whenContainedInInstancesOf: [MyCiewController.self]).tintColor = .orange
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .orange.withAlphaComponent(0.5)
appearance.backgroundEffect = UIBlurEffect(style: .systemChromeMaterialDark)
// Set different title colors for large and normal mode
appearance.titleTextAttributes = [.foregroundColor: .white]
appearance.largeTitleTextAttributes = [.foregroundColor: .black]
// No effect
appearance.buttonAppearance.normal.titleTextAttributes = [.foregroundColor: .white]
UINavigationBar.appearance(whenContainedInInstancesOf: [MyCiewController.self]).standardAppearance = appearance
So, setting different colors for large and normal title is no problem. However, I did not find any appearance property to do the same for the bar button items. My best guess was to use buttonAppearance
but this had no effect.
How to make the "Done" button white in the normal nav bar? Is it possible to use appearances to solve this?
Upvotes: 1
Views: 251