I want to create slider in SwiftUI with Value label.
I have write below code.
struct SliderView: View {
@State private var speed = 50.0
var minValue: Double = 1
var maxValue: Double = 100
var body: some View {
VStack {
Text("\(speed,specifier: "%.f")")
.foregroundColor(.blue)
Slider(
value: $speed,
in: minValue...maxValue,
step: 1
) {
Text("Speed")
} minimumValueLabel: {
Text("\(minValue,specifier: "%.f")")
} maximumValueLabel: {
Text("\(maxValue,specifier: "%.f")")
}
}.padding()
}
}
But I want to move value label with slider thumb.
I am not able to find any property to set .frame for Y value.
Question:
How to move Slider Value label with Thumb and move label value with Thumb change.



