CocoaPods trunk is moving to be read-only. Read more on the blog, there are 12 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Sep 2016 |
| SPMSupports SPM | ✗ |
Maintained by Jay Abbott.
A framework for performing animations on any properties using custom curves.
Requires: Xcode 8, Swift 3.0
Animatable protocol to a list so they will receive an update call in sync with the display refresh.Curve classes to simplify your code.CompositeCurve or by implementing the Parametric protocol.You can install and use this Framework with Cocoapods, or by manually adding the Animation project into your workspace and updating the build settings.
Animation.xcproject project into your Workspace.Animation.framework with your targets in the target/build settings.Import the module:
import AnimationPerform fire-and-forget animations:
let startPoint = CGPoint(x: 10, y: 10)
let endPoint = CGPoint(x: 100, y: 100)
let startColor = UIColor.black
let endColor = UIColor.red
Animation.animate(identifier: "example", duration: 0.5,
update: { (progress) -> Bool in
myView.center = startPoint <~~ Curve.easeInEaseOut[progress] ~~> endPoint
myView.backgroundColor = startColor <~~ progress ~~> endColor
return true
})What’s going on:
The Animation.animate(identifier:duration:update:completion:) function starts an animation immediately, calling your update code repeatedly (in sync with the display refresh) for the specified duration. Within the update closure, a UIView instance is updated by changing its center and backgroundColor properties. You can perform any calculations, and update whatever properties you like, including ones that aren’t normally animatable using UIKit animnations. The interpolation operators are used to get an interpolated value between the start and end values, for example 10.0 <~~ 0.1 ~~> 20.0 would return a value 0.1 of the way from 10.0 to 20.0, i.e. 11.0. The progress parameter is used to perform linear interpolation of the backgroundColor and the Curve.easeInEaseOut object is used to convert the linear progress into an ease-in-ease-out curve to animate the position.
Import the module:
import AnimationAdopt the Animatable protocol:
class MyAnimatableClass: Animatable {Conform to the Animatable protocol:
func update(by timeInterval: Double) {
// Do whatever you want, using timeInterval to calculate the new position of things
}Add your instance to receive updates:
Animation.add(animatable: self)