SwiftUI - Stepper Example.
The Stepper control is equivalent to UIStepper in Swift. SwiftUI introduce a class called Stepper. Stepper provide a simple way to change a numeric value. Stepper contains of +/- symbols that increment/decrement of internal value. first you create SwiftUI Project.
Before the start of the code you will know Text in Swift, We are taking Text and Stepper in this code.
Full Code of Stepper SwiftUI
// Created by Kirit Modi on 17/09/19.
// Copyright © 2019 iOSDevCenters. All rights reserved.
//
import SwiftUI
struct ContentView: View {
@State var items: Int = 0
var body: some View {
ZStack {
Stepper(value: $items, in: 0...50, label: {
Text("My Value: \(items)")
.foregroundColor(Color.red)
.background(Color.yellow)})
.padding()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Output:
SwiftUI - Stepper Example.
Reviewed by KIRIT MODI
on
00:28:00
Rating:
No comments: