With iOS 16, the toolbar and toolbarItem are working differently. On iOS 14/15, when adding two toolbars one after another, the second one overrides the first one. With iOS 16, the content from the second one extends the content of the first one. What I tried was to set ids for toolbar and toolbarItem hoping will have the same behaviour as on iOS 14/15 but it's not really working.
Desired behaviour is the one from iOS 14/15 and it looks like this:
Current behaviour for iOS 16:
This is my code which is working ok for iOS 14/15:
struct RootView: View {
var body: some View {
NavigationView {
Text("Hello, World!").padding()
.navigationTitle("navigation title")
.navigationBarTitleDisplayMode(.inline)
.toolbar(id: "toolbar_id") {
ToolbarItem(id: "toolbaritem_id", placement: .navigationBarLeading) {
Button("Button 1") {
print("Pressed Button 1")
}
}
}
.toolbar(id: "toolbar_id") {
ToolbarItem(id: "toolbaritem_id", placement: .navigationBarLeading) {
Button("Button 2") {
print("Pressed Button 2")
}
}
}
}
.navigationViewStyle(.stack)
}
}