SwiftUI How to push to next screen when tapping on Button

前端 未结 5 915
囚心锁ツ
囚心锁ツ 2020-12-21 18:02

I can navigate to next screen by using NavigationButton (push) or present with PresentationButton (present) but i want to push when i tap on Buttton()

Button         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-21 18:41

    To tap on button and navigate to next screen,You can use NavigationLink like below

    NavigationView{
           NavigationLink(destination: SecondView()) {
                 Text("Login")
                  .padding(.all, 5)
                  .frame(minWidth: 0, maxWidth: .infinity,maxHeight: 45, alignment: .center)
                  .foregroundColor(Color.white)
           }
     }
    

提交回复
热议问题