如果没有模态或导航 View (列表)方法,我们如何在独立屏幕之间导航(无法返回)?
有办法做到这一点吗?
最佳答案
欢迎来到 Stackoverflow。是的,有一些方法可以做到这一点。
这篇 Medium 文章是您可以引用的一个很好的引用: https://medium.com/swlh/customize-your-navigations-with-swiftui-173a72cd8a04
它的 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()
})
}
}
关于ios - SwiftUI 不同 View 之间的导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60609086/