iPhone SwiftUI layouts
Explore interactive SwiftUI previews across every available iPhone screenshot variant.
201elements
Toggle
Multiple Sources Toggle
Creates a toggle that updates the selected property for all sources. Once toggled, all sources will have the same value.
SwiftUI code
struct Cat: Identifiable {
let id = UUID()
var name: String
var isHungry: Bool
}
@State private var sources = [
Cat(name: "Bella", isHungry: false),
Cat(name: "Max", isHungry: true)
]
var body: some View {
List {
Toggle("Foo1", sources: $sources, isOn: \.isHungry)
ForEach(sources) { pet in
Text("\(pet.name): \(pet.isHungry ? "😾" : "😻")")
}
}
}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 Toggle.