Multiple Sources Picker
Creates a picker that updates the selected property for all sources.
Platform Compatibility
Tags
SwiftUI Code
enum SpecialProperty: String, CaseIterable, Identifiable {
case small, medium, large
var id: String { rawValue }
}
struct Cat: Identifiable {
let id = UUID()
var name: String
var size: SpecialProperty
}
@State private var sources = [
Cat(name: "Bella", size: .small),
Cat(name: "Max", size: .large)
]
var body: some View {
List {
Picker("Size for all pets", sources: $sources, selection: \.size) {
ForEach(SpecialProperty.allCases) { size in
Text(size.rawValue).tag(size)
}
}
ForEach(sources) { pet in
Text("\(pet.name): \(pet.size.rawValue)")
}
}
}Found an issue or have a suggestion?
More Picker Components
View allTabsPickerStyle
A picker style that presents options as segmented tabs. On macOS, this style produces a segmented picker with a visual treatment that distinguishes tab navigation from value selection. On iOS, tvOS, and visionOS, the visual appearance matches that of the standard standard .segmented style. On all supported platforms, VoiceOver announces options as tabs.
Horizontal Radio Group Layout
Sets the style for radio group style pickers within this view to be horizontally positioned with the radio buttons inside the layout.
WheelPickerStyle
A picker style that presents the options in a scrollable wheel that shows the selected option and a few neighboring options.
SegmentedPickerStyle
A picker style that presents the options in a segmented control. Use this style when there are two to five options. Consider using menu when there are more than five options.
PalettePickerStyle
A picker style that presents the options as a row of compact elements. When used outside of menus, this style is rendered as a segmented picker. If that is the intended usage, consider segmented instead.
Explore Other Components
Browse allCustom Icon Store View
Creates a view to load a collection of products from the App Store using product identifiers, and merchandise them using a custom image.
CircularProgressViewStyle
The style of a progress view that uses a circular gauge to indicate the partial completion of an activity
AccessoryCircularCapacityGaugeStyle
A gauge style that displays a closed ring that’s partially filled in to indicate the gauge’s current value
Gauge
Creates a gauge showing a value within a range and describes the gauge’s purpose and current value
Custom Slider Ticks
Creates a slider to select a value from a given range, subject to a step increment, which displays the provided labels and customizable ticks.
LinearProgressViewStyle
A progress view that visually indicates its progress using a horizontal bar