JJValueAnimator 1.2

JJValueAnimator 1.2

Juan J LF 维护。



  • only-icesoul

JJValueAnimator

Version License Platform

需求

 ios platform 12

安装

JJValueAnimator 可由 CocoaPods 提供。要安装它,只需将下列行添加到您的 Podfile 中

pod 'JJValueAnimator'

示例

要运行示例项目,请先将(repo)克隆,然后在 Example 目录中首先运行 pod install

您可以做什么?

demo

使用说明

ValueAnimator 使从初始值到目标值的过渡。

简单的线性动画

import JJValueAnimator

let anim = JJValueAnimator.ofFloat(0, to: 100).addUpdateListener({
            [weak self ] (value) in
                // do something with value
            })
        .setDuration(400) // millis
       
anim.start()

线程

JJValueAnimator 使用当前线程。

插值器

用于计算动画经过时间的插值器。默认值是线性。

插值器 以 JJInterpolator 开始。

import JJValueAnimator

let  anim = JJValueAnimator...
anim.setInterpolator(JJInterpolator(ease: .ANTICIPATEOVERSHOOT))

// or

anim.setInterpolator(JJInterpolatorCycle(cycles: 4))

自定义插值器

需要实现 JJTimeInterpolator 协议

class MyInterpolator : JJTimeInterpolator{


    override func getInterpolation(input: Float) -> Float {
        //do the magic
    }

}

anim.setInterpolator(MyInterpolator())

监听器

有 JJAnimatorListener 和 JJAnimatorPauseListener

 anim.addListener(OnAnimationListener(self))
 anim.addPauseListener(MyAnimatorPauseListener(self))