ACAnimator 1.0.1

ACAnimator 1.0.1

Alejandro Cotilla 维护。



ACAnimator

Version License Platform

ACAnimator 允许您在 iOS 或 tvOS 上对几乎任何内容进行动画(包括不可动画的属性)。它还可以用于对逻辑变化进行“动画化”,而不仅仅是视觉上的(例如,淡入淡出音频)。它支持超过 30 种不同的缓动函数,并使用 CADisplayLink 提供最佳性能。

示例

Demo

要运行示例项目,首先要克隆存储库,然后在 Example 目录中运行 pod install

使用

// A random element
let box = UIView(frame: CGRect(x: 0, y: 200, width: 40, height: 40))
box.backgroundColor = .red
view.addSubview(box)

// Determine the target value
let targetX = UIScreen.main.bounds.width - box.frame.width

// Prepare and run the animation
let animator = ACAnimator(duration: 3.0, easeFunction: .expoInOut, animation: { (fraction, _, _) in
    // Calculate the proper value for the current "frame"
    let newValue = targetX * CGFloat(fraction)
    
    // Apply the new value
    box.transform = CGAffineTransform(translationX: newValue, y: 0)
    
    // NOTE: the `transform` property is animatable through UIKit or CoreAnimation, this example just showcases the equivalent implementation using ACAnimator.
})
animator.start()

安装

CocoaPods

ACAnimator可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile文件中。

pod 'ACAnimator'

手册

只需将ACAnimator.swift文件拖入您的项目中。

作者

acotilla91,[email protected]

许可协议

ACAnimator遵循MIT许可协议。详细信息请参阅LICENSE文件。