Is there a way to keep the menu open after tapping on a button or toggle inside it instead of automatically minimizing it on every tap?
This isn't a feature that's going to production ever, by the way.
My code is something like this:
struct MyView: View {
@State var toggleA = true
@State var toggleB = true
@State var toggleC = true
var body: some View {
NavigationView {
SwiftUI.Form {
Text("Hello")
}
.navigationTitle("My View")
.navigationBarTitleDisplayMode(.inline)
.navigationBarItems(trailing: {
Menu {
Toggle("A", isOn: $toggleA)
Toggle("B", isOn: $toggleB)
Toggle("C", isOn: $toggleC)
} label: {
Image(systemName: "ellipsis.circle")
}
}())
}
}
}
struct Preview: PreviewProvider {
static var previews: some View {
MyView()
}
}
API supporting this was added in iOS 16.4 (docs)
Menu {
...
}
.menuActionDismissBehavior(.disabled)