Hi everyone! I recently noticed a strange behaviour with the new SwiftUI Toolbar.
I have an app with only 2 views: a ContentView and a DetailView. My goal is to have a different toolbar in both.
ContentView:
DetailView:
When I toggle the @Binding property in the DetailView, the toolbar is replaced by another empty toolbar appearing from nowhere.
Am I doing something wrong?
I have an app with only 2 views: a ContentView and a DetailView. My goal is to have a different toolbar in both.
ContentView:
Code Block struct ContentView: View { @State var isFavorite = false var body: some View { NavigationView { VStack { Image(systemName: isFavorite ? "star.fill" : "star") NavigationLink(destination: DetailView(isFavorite: $isFavorite)) { Text("Go") } } .navigationTitle("ContentView") .toolbar() { ToolbarItem(placement: .bottomBar) { Text("This is my ContentView") } } } } }
DetailView:
Code Block struct DetailView: View { @Binding var isFavorite: Bool var body: some View { Button("Tap me!") { isFavorite.toggle() } .navigationTitle("DetailView") .toolbar() { ToolbarItem(placement: .bottomBar) { Text("This is my DetailView") } ToolbarItem(placement: .navigationBarTrailing) { Image(systemName: isFavorite ? "star.fill" : "star") } } } }
When I toggle the @Binding property in the DetailView, the toolbar is replaced by another empty toolbar appearing from nowhere.
Am I doing something wrong?