Contents

SliderTick

A representation of a tick in a slider, with associated value and optional label.

Declaration

struct SliderTick<V> where V : BinaryFloatingPoint

Overview

The following example shows a slider bound to the value percentage. As the slider updates the currentValueLabel. The slider also renders marks at a 0.25 step interval.

@State private var percentage = 0.5

Slider(value: $percentage) {
    Text("Percentage")
} currentValueLabel: {
    Text("\(percentage)%")
} ticks: {
    SliderTickContentForEach(
        stride(from: 0.0, through: 1.0, by: 0.25).map { $0 },
        id: \.self
    ) { value in
        SliderTick(value) {
            label(for: value)
        }
    }
}

Topics

Structures

Initializers

Instance Properties

See Also

Adding ticks to a slider