IsaacYoung
V2EX  ›  Swift

SwiftUI transition 关联 animation 不生效

  •  
  •   IsaacYoung · Jul 11, 2020 · 2790 views
    This topic created in 2153 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   ·   5792 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 03:20 · PVG 11:20 · LAX 20:20 · JFK 23:20
    ♥ Do have faith in what you're doing.