I have a Picker
in my SwiftUI View
with the new MenuPickerStyle
.
As you can see, the label of the picker is same of the options, and it becomes dim when changing from one option to another.
It looks like it is not tappable, but when tapping it does the required job.
Here's my code. It is just a very simple picker implementation.
struct MenuPicker: View {
@State var selection: String = "one"
var array: [String] = ["one", "two", "three", "four", "five"]
var body: some View {
Picker(selection: $selection, label: Text(selection).frame(width: 100), content: {
ForEach(array, id: \.self, content: { word in
Text(word).tag(word)
})
})
.pickerStyle(MenuPickerStyle())
.padding()
.background(Color(.systemBackground).edgesIgnoringSafeArea(.all))
.cornerRadius(5)
}
}
struct ContentView: View {
var body: some View {
ZStack {
Color.gray
MenuPicker()
}
}
}