SwiftUI iOS 15 how to change the color of navigation bar items

Viewed 289

After I update to iOS 15 Xcode 13 the following code is not working anymore, is there any new way to change the color of the navigation bar items on iOS 15?

(Updated: I use SwiftUI)

enter image description here

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()
appearance.backgroundColor = .systemBackground
appearance.titleTextAttributes = [.foregroundColor: UIColor.label]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.label]
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance appearance
UINavigationBar.appearance().tintColor = .label

-- Updated at 2021.10.18 --

Expected:

enter image description here

enter image description here

Actual:

enter image description here enter image description here

My code works fine in light mode. However my code does not works in dark mode on iOS 15.

0 Answers
Related