IsaacYoung
V2EX  ›  Swift

SwiftUI transition 关联 animation 不生效

  •  
  •   IsaacYoung · Jul 11, 2020 · 2796 views
    This topic created in 2157 days ago, the information mentioned may be changed or developed.

    点击按钮使 Text 展示出来,在 transition 的使用 animation 设置延迟 2s,实际结果并没有延迟,为什么使用 .opacity 可以, 使用.offset 无法出发动画效果,求大佬

    
    
    import SwiftUI
    
    struct ContentView: View {
        @State private var show = false
        
        var body: some View {
            VStack {
                Spacer()
                
                if show {
                    Text("AAAA")
                        .transition(
                            AnyTransition
                                //                            .offset(x: 100, y: 100)
                                .opacity
                                .animation(
                                    Animation
                                        .easeInOut(duration: 1)
                                        .delay(5)
                            )
                    )
                }
                
                Spacer()
                
                Button("点击") {
                    self.show.toggle()
                }
                .padding()
            }
        }
    }
    
    
    
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3067 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:22 · PVG 22:22 · LAX 07:22 · JFK 10:22
    ♥ Do have faith in what you're doing.