SwiftUI--计数器(一)
2019-06-29 本文已影响0人
白色天空729
struct ContentView : View {
@State var count : Int = 0
var body: some View {
VStack(alignment:.leading) {
Text("current count:\(count)")
Button(action: {
self.count += 1
}) {
Text("点我增加")
}
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
效果图:
QQ20190629-100114-HD.gif