SwiftUI Stepper

Main Idea

Stepper: a simple - and + button that can be tapped to select a precise number. We can set a range and step.

struct ContentView: View {
    
    @State private var sleepAmount = 8.0
    
    var body: some View {
        Stepper("\(sleepAmount.formatted()) hours", value: $sleepAmount, in: 4...12, step: 0.25)
    }
}

Notes mentioning this note


Here are all the notes in this garden, along with their links, visualized as a graph.