1

I want to navigate between the login screen to sign up Screen with the help of button action.

   Button(action: {

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

                print("Join button tapped!!")
                   })
sfung3
  • 2,227
  • 1
  • 9
  • 30
Ankit Negi
  • 15
  • 3
  • 2
    Does this answer your question? [How to navigate using button with condition check in SwiftUI](https://stackoverflow.com/questions/58525213/how-to-navigate-using-button-with-condition-check-in-swiftui) – Asperi Feb 27 '20 at 06:17
  • I just want to navigate between controllers with help of UIButton in swiftUI. One screen to another – Ankit Negi Feb 27 '20 at 06:37
  • 1
    You can define a `@State` variable, set it in NavigationLink isActive param and toggle your variable in button action – Mac3n Feb 27 '20 at 07:20
  • @Mac3n, I am new in swiftUI field can you show me any demo of navigation between controllers with help of button action? – Ankit Negi Feb 28 '20 at 10:48
  • what type of navigation you need ? present a screen or navigate using push action ? – Mac3n Feb 28 '20 at 20:37
  • @Mac3n navigate using push action. – Ankit Negi Mar 02 '20 at 06:21

1 Answers1

0

You can create navigation link and set properties to show it like button: Here is my code:

    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)
        }
    }

Here is how it looks:

enter image description here

Hope it helps..Good Luck :)

Gautam Shrivastav
  • 1,198
  • 1
  • 9
  • 22