Search code examples
swiftuitoolbar

watchOS multiple toolbar items


my goal is to have 2 buttons as a toolbar item in my WatchOS app, but even if I group them in a toolbargroup or place multiple toolbarItems on their own, there is only one that is shown. Any idea what is wrong here ?

.toolbar {
    ToolbarItem {
        Button("1") {
        }
    }
    ToolbarItem {
        Button("2") {
        }
    }
}

or

.toolbar {
    ToolbarGroup {
        Button("1") {
        }
        Button("2") {
        }
    }
}

Solution

  • Ok, found it. Placing them in a Stack (V or H) works

    .toolbar {
        ToolbarGroup {
            VStack {
                Button("1") {
                }
                Button("2") {
                }
            } 
        }
    }