Library / Pickers, sliders & steppers

Picker wheel ticks

A custom wheel or scrubber that ticks once per row as it spins past values.

0ms 100ms 200ms 300ms 400ms
Feel
The classic clock-picker feel: light, dry ticks in rhythm with the scroll.
APIs
UISelectionFeedbackGenerator.sensoryFeedback(.selection)
Minimum OS
iOS 10+
Raw .md
SwiftUI (iOS 17+)
import SwiftUI

struct MinutePicker: View {
    @State private var minutes = 5

    var body: some View {
        Picker("Minutes", selection: $minutes) {
            ForEach(0..<60, id: \.self) { Text("\($0) min") }
        }
        .pickerStyle(.wheel)
        // System wheels tick on-device already; this pattern is for
        // custom scrubbers bound to any changing value:
        .sensoryFeedback(.selection, trigger: minutes)
    }
}
UIKit (custom scrubber)
final class Scrubber: UIScrollView, UIScrollViewDelegate {
    private let tick = UISelectionFeedbackGenerator()
    private var lastIndex = 0
    private let rowHeight: CGFloat = 36

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let index = Int(round(scrollView.contentOffset.y / rowHeight))
        if index != lastIndex {
            lastIndex = index
            tick.selectionChanged()
            tick.prepare() // stay armed for fast flicks
        }
    }
}
Copied