簡體   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