I see two separate issues here.
Firstly, the display of Picker labels, and Pickers themselves, is platform-specific.
This code will behave differently on iOS and macOS.
(Hint tag your questions, to make the Platform clear to helpers!)
On iOS, the label, which is Text("Select Favorite Fruit"), will not show.
On macOS, it will.
But is that what @RadApps is asking about?
Or do they mean...
An obscure UI bug, where, after using the Picker to select, the selected item does not show correctly.
I can reproduce this.
It is fixable by adding some content above the Picker...
...or even by adding some padding to the top of the Picker, like this:
struct ExampleView: View {
var fruits = ["Banana","Apple", "Peach", "Watermelon", "Grapes" ]
@State private var selectedFruit = 0
var body: some View {
VStack {
Picker("Select Favorite Fruit", selection: $selectedFruit) {
ForEach(0..<fruits.count) {
Text(self.fruits[$0])
.padding()
}
}
.padding(.top, 20) /// Workaround for obscure UI issue
.pickerStyle(MenuPickerStyle())
Text("Your Favorite Fruit: \(self.fruits[selectedFruit])")
}
}
}