In SwiftUI, the built in DatePicker has two buttons, each of which when clicked displaying a pop up menu with a highly customized view (a calendar, and a multi-component wheel picker respectively).
How can I recreate a similar setup but with a custom button and my own wheel style picker in the menu? For example, I'm trying to create a duration picker in the same style as the DatePicker. Unfortunately, a Picker placed inside a Menu simply does not render when rendered with the .wheel style. Alternatives like using the default picker .menu style doesn't allow for the same experiences as the setup found in DatePicker. Using a context menu also isn't quite right as it requires a long press and blurs the rest of the screen when open (plus the wheel picker is broken in this view too).
Minimal reproducible example: clicking Test does not even open the menu. Note that adding a .frame(width: 100, height: 100) or fixedSize() to the picker does not help.
struct ExampleView: View {
@State var selection = 1
var body: some View {
Menu("Test") {
Picker("Test", selection: $selection) {
ForEach(0..<10) {
Text("\($0)").tag($0)
}
}
.pickerStyle(.wheel)
}
}
}
