SwiftUI - Using Sliders

From PeformIQ Upgrade
Revision as of 10:00, 31 July 2024 by PeterHarding (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Using Sliders

See - https://developer.apple.com/documentation/swiftui/slider

Slider(value: $bottomTrailing, in: 0...200, step: 5, minimumValueLabel: Text("0"), maximumValueLabel: Text("200")) {}.padding()
@State private var speed = 50.0
@State private var isEditing = false


var body: some View {
    VStack {
        Slider(
            value: $speed,
            in: 0...100,
            onEditingChanged: { editing in
                isEditing = editing
            }
        )
        Text("\(speed)")
            .foregroundColor(isEditing ? .red : .blue)
    }
}