我显示了一个现有视图。在显示该视图2秒钟后,我要浏览或显示另一个视图。以下代码不起作用。
return[${env.SERVERS_LIST}]
答案 0 :(得分:0)
在纯SwiftUI中,您将执行以下操作:
struct ContentView: View {
@State private var showFirst = true
var body: some View {
Group {
if showFirst {
StartView()
} else {
SecondView()
}
}
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
self.showFirst = false
}
}
}
}
struct StartView: View {
var body: some View {
Text("First")
}
}
struct SecondView: View {
var body: some View {
Text("Second")
}
}