SwiftUI How to push to next screen when tapping on Button

前端 未结 5 918
囚心锁ツ
囚心锁ツ 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:35

    You need to use navigationBarBackButtonHidden by setting it true in your destination View like this below :-

    struct ContentView: View {
        var body: some View {
            NavigationView {
                NavigationButton(destination: DetailView()) {
                    Text("Click Me")
                }.navigationBarTitle(Text("Header"))             }
        }
    }
    struct DetailView: View {
        var body: some View {
            Text("Detail View")
            .navigationBarBackButtonHidden(true) //This will hide your back arrow button
    
        }
    }
    

提交回复
热议问题