2

can I change navigationBarTitle color when touched a button?

NavigationView {
    ZStack {
        Color(ThemeManager.shared().generalBackgroundColor)
            .edgesIgnoringSafeArea(.all)
    }    .navigationBarTitle("Change theme sample").foregroundColor(.blue)
}
LuLuGaGa
  • 13,089
  • 6
  • 49
  • 57
quynhbkhn
  • 59
  • 4

1 Answers1

1

You cannot currently change navigation bar properties in SwiftUI natively, so your .foregroundColor(.blue) will just change all the foreground colors on that screen.

You can use something like this answer to gain access to the UINavigationController and then change the large title bar with navigationController.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.blue].

arsenius
  • 12,090
  • 7
  • 58
  • 76