Difference between revisions of "SwiftUI - Using Sliders"

From PeformIQ Upgrade
Jump to navigation Jump to search
(Created page with "=Using Sliders = See - https://developer.apple.com/documentation/swiftui/slider <pre> Slider(value: $bottomTrailing, in: 0...200, step: 5, minimumValueLabel: Text("0"), maximumValueLabel: Text("200")) {}.padding() </pre> Category:SwiftUI Category:Examples")
 
 
Line 5: Line 5:
<pre>
<pre>
Slider(value: $bottomTrailing, in: 0...200, step: 5, minimumValueLabel: Text("0"), maximumValueLabel: Text("200")) {}.padding()
Slider(value: $bottomTrailing, in: 0...200, step: 5, minimumValueLabel: Text("0"), maximumValueLabel: Text("200")) {}.padding()
</pre>
<pre>
@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)
    }
}
</pre>
</pre>


[[Category:SwiftUI]]
[[Category:SwiftUI]]
[[Category:Examples]]
[[Category:Examples]]

Latest revision as of 10:00, 31 July 2024

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)
    }
}