美文网首页
iOS动画-UIView动画(transform)

iOS动画-UIView动画(transform)

作者: 肖旭晖 | 来源:发表于2019-04-02 18:06 被阅读0次

https://www.jianshu.com/p/3f21e81e09dd
https://www.jianshu.com/p/3f21e81e09dd

duration
isRemovedOnCompletion
autoreverses
repeatCount HUGE
fillMode
keyTimes
calculationMode 添加上计算模式属性,让动画更平滑
values
path

六. CASpringAnimation(弹簧动画)

      let redView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        redView.backgroundColor = .red
        redView.center = view.center
        view.addSubview(redView)
        
        
        let animation = CASpringAnimation(keyPath: "transform.scale")
        animation.beginTime = CACurrentMediaTime() + 3
        animation.mass = 0.1 //设置质量,质量越大,惯性越大
        animation.damping = 1//设置阻尼系数,阻尼系数越大,停止越快
        animation.stiffness = 100 //设置刚性系数,刚性系数越大,运动越快
        animation.initialVelocity = 0.3 //初始速率
        animation.toValue = 2.0
        animation.isRemovedOnCompletion = false
        animation.repeatCount = HUGE
        animation.autoreverses = true
        animation.fillMode = .forwards
        animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
        animation.duration = animation.settlingDuration//设置动画时长
        redView.layer.add(animation, forKey: "scale")


image.png

https://www.jianshu.com/p/91b0cb25d4cb

相关文章

网友评论

      本文标题:iOS动画-UIView动画(transform)

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