Hi, when I try to use Picker inside a Form, inside a NavigationView it will always use the .menu style for the Picker. All tutorials, docs show the default renderings to have a new nav page rendered with the options.
I don't want this 'dropdown', I want my pickers to behave the same way they do in iOS system settings (new subpage with navigation).
I'm using the latest xcode, creating for iOS.
struct SettingsView: View {
@Binging var colorScheme: ColorScheme?
@State var selectedColorScheme: Int = 1
var body: some View {
NavigationView {
Form {
Section(header: Text("UI").foregroundColor(.secondary)) {
Picker("Color scheme", selection: $selectedColorScheme) {
Text("system default").tag(1)
Text("light theme").tag(2)
Text("dark theme").tag(3)
}.onChange(of: selectedColorScheme) { scheme in
switch scheme {
case 1:
colorScheme = nil
case 2:
colorScheme = .light
case 3:
colorScheme = .dark
default:
break
}
}
}
}
}
}
I believe in iOS 16.1 this feature was put back in SwiftUI, but in the form of a new picker style (since the default is .menu
). It's called .navigationLink
and is available from iOS 16.0.