简体   繁体   English

不同视图之间的 SwiftUI 导航

[英]SwiftUI Navigation between different VIEWS

How can we navigate between independent screens (no option to go back) without modal or navigationview (list) approach?我们如何在没有模态或导航视图(列表)方法的情况下在独立屏幕(没有返回选项)之间导航?

Is there a way to do this?有没有办法做到这一点?

Welcome to Stackoverflow.欢迎使用 Stackoverflow。 Yes, there are ways to do that.是的,有办法做到这一点。

One great reference you can have is this Medium article: https://medium.com/swlh/customize-your-navigations-with-swiftui-173a72cd8a04您可以获得的一个很好的参考是这篇 Medium 文章: https : //medium.com/swlh/customize-your-navigations-with-swiftui-173a72cd8a04

Its implementation of modalLink is not that complex to implement.它的modalLink实现并不复杂。

struct ContentView : View {
    @State var isPresented = false

    var body: some View {

        VStack {
            Button(action: {
                print("Button tapped")
                self.isPresented.toggle()
            }) {
               Text("LOGIN")
               .font(.headline)
               .foregroundColor(.white)
               .padding()
               .frame(width: 220, height: 60)
               .background(Color.green)
               .cornerRadius(15.0)
            }
        }.modalLink(isPresented: self.$isPresented, linkType: ModalTransition.fullScreenModal, destination: {
            DestinationView()
        })
    }
}

在此处输入图片说明

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

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