If you embed the Picker inside of a Menu, it lets you create a custom label. I'm not sure if this was intended by SwiftUI, but it seems to work perfectly as expected.
Menu {
Picker(selection: $selectedFruit, label: Text("Select Favorite Fruit")) {
ForEach(0..<fruits.count, id: \.self) {
Text(fruits[$0])
}
}
} label: {
HStack {
Text("Favorite Fruit")
Divider()
Text(fruits[selectedFruit])
}
}
Source: https://stackoverflow.com/q/70835085
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: