iPhone SwiftUI layouts
Explore SwiftUI APIs, components, and modifiers with interactive iPhone previews, Swift code, and Apple documentation. Compare every available orientation, appearance, and design.
206elements
Picker
Multiple Sources Picker
Creates a picker that updates the selected property for all sources.
Explore Multiple Sources Picker on iPhone in portrait, with SwiftUI code and Apple API documentation.
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)")
}
}
}Compatibility
iOS 16.0+ iPadOS 16.0+ macOS 13.0+ watchOS 9.0+ tvOS 16.0+ visionOS 1.0+
Tags
Found an issue or have a suggestion?
All variants
Every available iPhone screenshot for Multiple Sources Picker.