SwiftUI

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

视频地址:https://www.youtube.com/watch?v=P3Fs-oOLzHs

上一篇下一篇

猜你喜欢

热点阅读