Search code examples
xcodeswiftuinavigationbarwatchos-6

NavigationBarTitle color change for watchOS in SwiftUI


enter image description here

In the image above id like to change -02:49 to a color such as Color.blue

I've tried:

struct ContentView: View {

    var body: some View {
        PlayerView().accentColor(Color.blue)

    }
}

and I've also tried adding it in the actual PlayerView as follows:

struct PlayerView: View {

    var body: some View {
        VStack{
            .... 

        }.navigationBarTitle(Text(“-2:49”))
         .accentColor(.blue)

    }

}

I've also tried:

   struct PlayerView: View {

    var body: some View {
        VStack{
            .... 

        }.navigationBarTitle(Text(“-2:49”).foregroundColor(.blue))

    }

}

Solution

  • At this point for change color of navigationBarTitle their is no direct api in SwiftUI.

    But you can change it like this,
    1) Go to Interface.storyboard file inside your AppName WatchKit App.
    2) Select Hosting Controller Scene, Go to File Inspector and change Global Tint to your Custom Color.