繁体   English   中英

如何在swiftui中按钮操作的视图控制器之间导航?

[英]How to navigate between view controllers on a button action in swiftui?

我想在登录屏幕之间导航以在按钮操作的帮助下注册屏幕。

   Button(action: {

                NavigationLink(destination:SignUpScene()){
                   Text("Show Detail View")
                                  }

                print("Join button tapped!!")
                   })

您可以创建导航链接并设置属性以像按钮一样显示它:这是我的代码:

    var body: some View {
        NavigationView {

            //Button to navigate to another page
            NavigationLink(destination: AlertView()) {
                Text("GO TO ALERT")
                    .padding(15)
                    .frame(minWidth: 0, maxWidth: .infinity)
                    .background(Color.red)
                    .foregroundColor(Color.white)
                    .cornerRadius(4)
            }
            .padding([.leading, .trailing], 30)
            .padding([.top], 21)
            .frame(height: 50)
        }
    }

这是它的外观:

在此处输入图片说明

希望它有帮助..祝你好运:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM