Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 934 Bytes

README.md

File metadata and controls

57 lines (37 loc) · 934 Bytes

Stepper

Smart enough to bind to any number (i.e. Int, Double).

struct ContentView: View {
    
    @State private var sleepAmount = 8.0
    
    var body: some View {
        
        Stepper(value: $sleepAmount) {
            Text("\(sleepAmount) hours")
        }
        
    }
}

Limit range of steps like this.

Stepper(value: $sleepAmount, in: 4...12) {
    Text("\(sleepAmount) hours")
}

Adjust the step value.

Stepper(value: $sleepAmount, in: 4...12, step: 0.25) {
    Text("\(sleepAmount) hours")
}

Format %f.

Text("\(sleepAmount, specifier: "%.2f") hours")

Format %g removes insignificant zeros.

Text("\(sleepAmount, specifier: "%.2g") hours")

Links that help