V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
IsaacYoung
V2EX  ›  Swift

SwiftUI transition 关联 animation 不生效

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