0

在下面的简单应用程序中,我希望红色矩形随着缩放动画出现并随着幻灯片动画消失,但只执行消失动画。这是为什么?

struct ContentView: View {
    @State private var showDetails = false

    var body: some View {
        VStack {
            Button(action: {
                withAnimation {
                    self.showDetails.toggle()
                }
            }) {
                Text("Tap to show details")
            }

            if showDetails {
                Color.red
                    .frame(width: 100, height: 100, alignment: .center)
                    .transition(.asymmetric(insertion: .scale, removal: .slide))
            }
        }
    }
}
4

0 回答 0