I’m attempting so as to add a second line of buttons in my toolbar navigation view in SwiftUI in order that it appears to be like like this: Nevertheless, these backside buttons lose their performance. I put them in a HStack within the Toolbar like so:
HStack(spacing: 0) {
ForEach(searchChoices.allCases, id: .rawValue) {buttonType in
Button {
print("clicked (buttonType.rawValue)")
searchSelected = buttonType
} label: {
if buttonType == searchSelected {
Textual content(buttonType.rawValue)
.modifier(SearchTypeButton(buttonColor: Colour(hex: 0x2f2f2f)))
} else {
Textual content(buttonType.rawValue)
.modifier(SearchTypeButton(buttonColor: Colour(hex: 0x666666)))
}
}
}
}
This HStack
is positioned in a VStack
in a ToolbarItemGroup
object. Does anybody know why these buttons don’t discover when they’re clicked?
The ForEach
doesn’t appear to be the issue as a result of the button nonetheless doesn’t work when it is only one of them. Nevertheless, when it’s positioned exterior of the HStack
, it does work.