SwiftUI Toolbar bottombar background color will not change

225 Views Asked by At

enter image description here

I'm trying to change the color of my toolbar. I found the code

 .toolbarBackground(Color.blue, for: .navigationBar)

and tried to place it in different position in my code but without any success.

here is an example code with my bottombar. I would like to change the color of my bottom bar

truct ContentView: View {
var body: some View {
    NavigationStack {
        VStack {
            Text("Test")
                .toolbar{
                    ToolbarItemGroup(placement: .bottomBar){
                        Spacer()
                NavigationLink(destination: SecondView()) {
                    Image(systemName: "bag")}
                        Spacer()
                NavigationLink(destination: SecondView()) {
                    Image(systemName: "dollarsign.circle")}
                        Spacer()
                NavigationLink(destination: SecondView()) {
                    Image(systemName: "plus.circle")}
                        Spacer()
                NavigationLink(destination: SecondView()) {
                    Image(systemName: "minus.circle")}
                        Spacer()
                    }
                }
                .toolbarBackground(Color.blue, for: .bottomBar)
        }
    }
  }      
}

could you please point me in the right direction?

1

There are 1 best solutions below

0
On

I think you need to add:

.toolbarBackground(.visible, for: .navigationBar)