A closed range that describes the upper and lower bounds permitted by the stepper.
step
The amount to increment or decrement the stepper when the user clicks or taps the stepper’s increment or decrement buttons, respectively.
onEditingChanged
A closure that’s called when editing begins and ends. For example, on iOS, the user may touch and hold the increment or decrement buttons on a stepper which causes the execution of the onEditingChanged closure at the start and end of the gesture.
label
A view describing the purpose of this stepper.
Discussion
議論
Use this initializer to create a stepper that increments or decrements a binding to value by the step size you provide within the given bounds. By setting the bounds, you ensure that the value never goes below or above the lowest or highest value, respectively.
The example below shows a stepper that displays the effect of incrementing or decrementing a value with the step size of step with the bounds defined by range:
structStepperView: View {@Stateprivatevar value =0let step =5let range =1...50var body: someView {Stepper(value: $value, in: range, step: step) {Text("Current: \(value) in \(range.description) "+"stepping by \(step)") } .padding(10) }}