SwiftUI

SwiftUI-Button

2019-11-19  本文已影响0人  白色天空729

原文:https://iosdevcenters.blogspot.com/2019/09/swiftui-button-example-with-action.html

import SwiftUI

struct ContentView: View {
    @State private var showiOSDetail = false

    var body: some View {
        VStack {
            Button(action: {
                self.showiOSDetail.toggle()
            }) {
                Text("iOS Blog")
                .foregroundColor(Color.white)
            }
            .padding()
            .background(Color.blue)

            if showiOSDetail {
                Text("You are click on iOsDevCenters ")
                    .font(.headline)
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

效果如图:


image.png
上一篇下一篇

猜你喜欢

热点阅读