Hi,
I use a Picker in a NavigationView like this:
struct ContentView: View {
@State private var selectedFlavor = Flavor.chocolate
enum Flavor: String, CaseIterable, Identifiable {
case chocolate
case vanilla
case strawberry
var id: String { self.rawValue }
}
var body: some View {
NavigationView {
Form {
Picker("Flavor", selection: $selectedFlavor) {
Text("Chocolate").tag(Flavor.chocolate)
Text("Vanilla").tag(Flavor.vanilla)
Text("Strawberry").tag(Flavor.strawberry)
}
}
.navigationTitle(Text("I scream"))
}
}
}
Screen shot:
I would expect a title over the selection of "Flavor" when the Picker is opened in a new view (marked in red), but there is no title and I did not find out how to add one without altering the title of the parent view:
If you add a .navigationBarTitle() in the Form or Picker you only change the parent view title.
Do I miss something here or is it not possible to show the Picker title during selection in the new view?
I am using Xcode 13.0 and Swift 5 and the simulator for the screen shot ran iOS 15.0.
Thanks,
Christian