I am trying to understand transition animations in SwiftUI and it just doesn't work for me. In the following code, the transition after one second is immediate (no fade).
struct TestApp: App {
@State private var isReady: Bool = false
var body: some Scene {
WindowGroup {
if isReady {
Color.red
} else {
Color.blue
.transition(.opacity)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
withAnimation {
isReady = true
}
}
}
}
}
}
}