Swiftpack.co - satoshin21/Anima as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by satoshin21.
satoshin21/Anima 0.9.3
Anima is chainable Layer-Based Animation library for Swift5.
⭐️ 510
🕓 16 weeks ago
.package(url: "https://github.com/satoshin21/Anima.git", from: "0.9.3")

Version License Platform language Version Build Status MIT License Platform Carthage compatible


Anima is chainable Layer-Based Animation library for Swift5.
It support to make sequensial and grouped animation more easily.

is written as follows.

let startAnimations: [AnimaType] = [.moveByY(-50), .rotateByZDegree(90)]
let moveAnimations: [AnimaType] = [.moveByX(50), .rotateByZDegree(90)]
let endAnimations: [AnimaType] = [.moveByY(-50), .rotateByZDegree(90)]

    .then(group: startAnimations)
    .then(group: moveAnimations, options: labelAnimaOption(index: 0))
    .then(group: moveAnimations, options: labelAnimaOption(index: 1))
    .then(group: moveAnimations, options: labelAnimaOption(index: 2))
    .then(group: moveAnimations, options: labelAnimaOption(index: 3))
    .then(group: endAnimations, options: labelAnimaOption(index: 4))
    .then(group: [.scaleBy(0.0), .opacity(0.0)])

func labelAnimaOption(index: Int) -> [AnimaOption] {
    let labelAnima = labels[index]?.layer.anima

    return [.completion({


Anima require for Swift4 and greater than iOS9.0📱


  • Almost all timing modes from easings.set are implemented.
  • Spring Animation ( featured by CASpringAnimation )
  • Type-Safed Animation KeyPath ()


Move Position

If you want to translate CALayer.position relatively, use .moveByX(CGFloat), .moveByY(CGFloat), .moveByXY(x: CGFloat, y: CGFloat) AnimaTypes.


or destination is determined, use .moveTo(x: CGFloat, y: CGFloat).

※ Anima doesn't update CALayer.position value for animations. Because when update Layer-backed view's layer position value, It will be resetted to default value frequently.

Sequential Animation

Anima supports.

Group Animation

To run animation concurrently, you use CAAnimationGroup with CoreAnimation. In Anima, you can use Anima.then(group: ) to run some AnimaType concurrently.

Below is an example of how to run moving, scaling and rotating animations concurrently.

    .then(group: [.moveByX(200),

Animation Options

There are some options for Anima.

  • duration(TimeInterval)
  • timingFunction(TimingFunction) _ Change timing function defining the pacing of the animation. _ Default timing function is at Anima.defaultTimingFunction. If you do not set the timing function option, defaultTimingFunction is used. * Please read Anima.TimingFunction.swift
  • repeat(count: Float) * To run animation infinitely, set .infinity.
  • autoreverse
  • completion(() -> Void)

you can use these values as belows.

    .then(.moveByX(100), options: [.autoreverse,
                                   .repeat(count: 3),

Rotate Animation & AnchorPoint

AnimaType has 3 rotation animation type, .rotateByX, .rotateByY, .rotateByZ. and each animation type has 2 value types, degrees and radians. you use whichever you like.

and CALayer has AnchorPoint. Rotating, moving, or other Animations are affected by it. Default value is (0.5, 0.5). AnimaType.moveAnchor(AnimaAnchorPoint) can move layer's AnchorPoint.


or If you want to change only AnchorPoint, use Anima.then(setAnchor: AnimaAnchorPoint).

    .then(setAnchor: .topLeft)

Move Path

If you want to make moving animation more complex, use .movePath(path: CGPath, keyTymes: [Double]). Anima example app has sample of creating animation by drag gesture. you see it!

but It has any problems when you use with AnimaOption.autoreverse. so If you use it, please be careful of options.

Original KeyPath

If you want to animate other animatable values, You can use AnimaType.original(keyPath: String, from: Any?, to: Any) for it. CAEmitterLayer's animation is like this.

let layer = CAEmitterLayer()
layer.emitterPosition = CGPoint(x: 100.0, y:100.0)

    .then(.original(keyPath: #keyPath(CAEmitterLayer.emitterPosition), from: layer.emitterPosition, to: CGPoint(x: 200.0, y:200.0)))


To run the example project, clone the repo, open Anima.xcodeproj, and run target Anima iOS Example.



Anima is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Anima"

# If you want to use Swift 3 version, Please specify Anima version.

pod "Anima", "0.5.1"


Add github satoshin21/Anima to your Cartfile. Execute carthage update to install it.


Satoshi Nagasaka, satoshi.nagasaka21@gmail.com


Anima is available under the MIT license. See the LICENSE file for more info.


Stars: 510
Last commit: 22 hours ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 years ago
  • update Swift version 5.1

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics