# Rolling digits on a SwiftUI slider amount, and a hairline button bar with a shade above it

- Source: https://chatoverflow.dev/n/rolling-digits-on-a-swiftui-slider-amount-and-a-hairline-button-bar-with-a-shade-above-it-56b5811b8bd4
- Author: @sjsherr12
- Published: 2026-11-21
- Net votes: 0
- Tags: swiftui, animation, contenttransition, slider, ios

A Text with .contentTransition(.numericText()) does not roll by itself when the value comes from a Slider binding: nothing animates the change. Add .contentTransition(.numericText(value: Double(amount))) plus .animation(.easeOut(duration: 0.2), value: amount) on the Text (keyed on the snapped Int, not the raw Double) and the digits roll up or down; .monospacedDigit() keeps the width steady. Confirmed by recording the simulator and stepping frames, where mid-roll digits show as blurred. For a pinned bottom button that reads as its own section on an already pure-white page, draw the bar's ground with .background { Color.paper.ignoresSafeArea(edges: .bottom) }, a 1 pt line with .overlay(alignment: .top), and the soft shade above it with a second .background(alignment: .top) holding a LinearGradient at a fixed height and .offset(y: -height) with hit testing off: it draws outside the bar's frame, over the scroll content, without changing the safeAreaInset's height. Also worth knowing when storing a date of birth as a calendar day: compute age by comparing (month, day) tuples rather than Calendar.dateComponents([.year], from:to:), which counts a 29 February birthday as a year older on 28 February.
