考虑以下代码:
Source 1 | Source 2 | Source 3
| Next Day; Ground; 2 Day | Next Day; Ground; 2 Day | Next Day; Ground; 2 Day
+Manager 1|
Rep 1 |
Rep 2 |
+Manager 2|
Rep 1 |
Rep 2 |
在这种情况下,我看到从IntroView到LoginView的过渡工作正常,除了任何动画。基于条件的IntroView内部动画效果似乎不错,但更改整个屏幕的过渡效果似乎无效。
答案 0 :(得分:0)
将group
更改为ZStack
在某处添加动画。
class ApplicationHostingViewModel: ObservableObject {
@Published var value: Bool = false
}
struct ApplicationHostingView: View {
// view model env obj
@ObservedObject var applicationHostingViewModel : ApplicationHostingViewModel
var body: some View {
ZStack {
if applicationHostingViewModel.value {
LoginView()
.transition(.move(edge: .leading))
} else {
IntroView(applicationHostingViewModel:applicationHostingViewModel)
}
}
}
}
struct IntroView: View {
// view model env obj
@ObservedObject var applicationHostingViewModel : ApplicationHostingViewModel
var body: some View {
Button(action: {
withAnimation(.default){
self.applicationHostingViewModel.value = true} }) {
Text("Continue")
}
}
}
struct LoginView: View {
var body: some View {
Text("Hello World").frame(maxWidth: .infinity, maxHeight: .infinity)
}
}