sliderThumbVisibility(_:)
Sets the thumb visibility for Sliders within this view.
Declaration
nonisolated func sliderThumbVisibility(_ visibility: Visibility) -> some View
Parameters
- visibility:
The slider thumb visibility to apply.
Discussion
Use this modifier to override the default slider thumb visibility. For example, the code below creates a Slider without an indicator:
@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
}
)
.sliderThumbVisibility(.hidden)
Text("\(speed)")
.foregroundColor(isEditing ? .red : .blue)
}
}Note: On watchOS, the slider thumb is always visible.