美文网首页
SwiftUI 动画

SwiftUI 动画

作者: 小凡凡520 | 来源:发表于2019-10-18 16:04 被阅读0次
    struct PageView: View {
        
        @State private var showDetail = false
        
        var body: some View {
            Button(action: {
                self.showDetail.toggle()
            }, label: {
                Image("1")
                .scaleEffect(showDetail ? 5.5 : 1)
                    .animation(.easeInOut(duration: 13))
            })
        }
    }
    
    struct PageView_Preview: PreviewProvider {
        
        static var previews: some View {
            PageView()
        }
    }
    
    

    动画效果定义

    // Linear
    .animation(.linear)
    
    // Ease Animation
    .animation(.easeInOut(duration: 0.3))
    
    // Animation with Delay
    .animation(Animation.easeOut(duration: 0.6).delay(0.1))
    
    // Spring
    .animation(.spring())
    
    // Interpolating Spring
    .animation(.interpolatingSpring(stiffness: 100, damping: 10))
    
    .rotationEffect(Angle(degrees: 30))
    .rotation3DEffect(Angle(degrees: 60), axis: (x: 0, y: 10, z: 0))
    .scaleEffect(0.9)
    .blendMode(.hardLight)
    .blur(radius: 20)
    

    相关文章

      网友评论

          本文标题:SwiftUI 动画

          本文链接:https://www.haomeiwen.com/subject/emaimctx.html