SwiftUI - Using Sliders

From PeformIQ Upgrade
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)
    }
}