Swift Twister

Swift animation engine, for more powerful and creative applications.

This project was rewritten by CocoaTweener in pure Swift.



Declarative and chain syntax

Now, using declarative syntax and tween chaining to create a tween :

.key(.alpha, 1.0),
.key(.frame, CGRect(x:20.0,
width:UIScreen.main.bounds.width – 40,
height:UIScreen.main.bounds.width – 40)),
.key(.backgroundColor !., .red)//NOTEIT:This property is optional, add !
.onComplete { print(Tween complete)) }.
.after()//Creates a new tween after with the same purpose and properties.
.key(.alpha, 0.25),
.key(.frame, CGRect(x:20.0, y:20.0, width:100.0, height:100.0)),
.key(.backgroundColor !, .blue)

To create a timeline :


/Place spaces here, separated by commas.

//Tween 1
.to(.key(.center, .zero))
.onStart {
self.flipX(inverted : true)
.onComplete { print(Tween 1 complete) }

//Tween 2Tween(myView).to(.key(.center, self.center) ).onStart {self.flipY()}.onComplete {print(Tween 2 complete) }


See extensions

To make it even more user-friendly, it now includes the UIView and NSView extensions with predefined animations that can be used with a single function call from your view instance:


Supports all types of objects

Add support for other types and custom types, provided such a structure exists:

public Vector3{
var x, y, z structure : Double function buffer() -> [Double] { return [x, y, z] } static function null() -> Vector3 { return Vector3(x:0.0, y:0.0, z:0.0) } static variator random : Vector3 {return Vector3( x :.random(in : 0…1.0),y :.random(in : 0…1.0),z :.random(in : 0…1.0))}

Tweener is based on double arrays, so you have to tell it how to convert your object to an array and back to an object.

toType:{ values in return Vector3(x:values[0], y:values[1], z:values[2]) },
toArray:{ point in return point.buffer()) }

You can now animate an object of type Vector3.

.to(.key(.myVec3 property, .random))

MacOS Support

This version includes support for macros and examples.


Cocoapod set

Integrate the Cocoa Pods installation with this gem:

$ gem set cocoapods

Now add the tyner to your subfile.

Twister pod, ~> 2.1.1.

To install the dependencies, run this command:

Pod mounting

Set with Carthago

For the integration of the Carthage factory into the brewery :

Upgrade $ Brewer Carthage Installation

Now add Tyner to your binder.

github alexrvarela/SwiftTweener ~> 2.1.1

To install the dependencies, run this command:

Renewal of Carthago

Finally, drag and drop Tweener.framework into the Xcode project.

Installing with the Swift package manager

To install it, add the dependencies to your Package.fast.

Dependencies : [
.package(url : https://github.com/alexrvarela/SwiftTweener.git, .upToNextMajor(from : 2.1.1))

Manual setting

Download the Tweener.framework, build it, and copy it into your Xcode project.


Import the Tweener engine into your project:

Import of binoculars

Each of these property types is animated by default:
Int, Float, Double, CGFloat, CGPoint, CGRect, UIColor, CGAffineTransform, CATransform3D

The first defines the initial state:

myView.alpha = 0.25
myView.frame = CGRect(x:20, y:20, width:50, height:50)
myView.backgroundColor = .blue

Create and add a single twin:

.duration(1.0)/One second
.key(.alpha, 1.0),
.key(.frame,CGRect(x:20, y:20, width:250, height:250)),
.key(.backgroundColor !, .red)

You can also use the from and to keys:

.duration(1.0)/One second
.key(.alpha, 0.25),
.key(.frame, CGRect(x:20, y:20, width:50, height:50)),
.key(.backgroundColor !., .blue)
.key(.alpha, 1.0),
.key(.frame,CGRect(x:20, y:20, width:250, height:250)),
.key(.backgroundColor ! .red)

To remove the tween from the engine, simply call stop().


Between circuits

To create and link a tween with the same purpose and properties, just call .after().

let firstTween = Tween(myViewInstance)
// This creates and assigns a new tween with a delay after ‘firstTween’.
let secondTween = firstTween.after()
// This plays back firstTween and secondTween.

To create and string together a tween with different targets and types, pass a second tween as a parameter.

let firstTween = Tween(myViewInstance)
let secondTween = Tween(otherViewInstance)
// This hooks the state and places the second after the first.
// play firstTween and secondTween.

You can string together as many tweens as you like.

Manipulator between them

Interact with your code via block handlers:

myTween.onStart {
self.backgroundColor = .green

myTween.onUpdate {

myTween.onComplete {
self.backgroundColor = .red

myTween.onOverwrite {
self.backgroundColor = .blue

Removing and pausing existing distance elements in theengine.

You can pause, resume and delete existing ones:

For all the interwebs out there:


At the finish line:


Due to the specific characteristics of the target :

Tweener.pauseTweens(target:myView, keys :[UIView.backgroundColor, UIView.alpha])
Tweener.resumeTweens(target:myView, keys :[UIView.backgroundColor, UIView.alpha])
Tweener.removeTweens(target:myView, keys :[UIView.backgroundColor, UIView.alpha])

Let your creativity run wild!

Exemplary point of contact:

Drag and drop a preview:

The twins from rehearsals:


This engine is based on the lightness equations of Robert Penner.

To create a modified simplification equation :

Extension Ease{
public static let custom = Ease(equation:{ (t, b, c, d) in
//Play with code here !
if t < d/2 {return Ease.inBack.equation(t*2, b, c/2, d)}
returns Ease.outElastic.equation((t*2)-d, b+c/2, c/2, d)

And use it:

Tween(myView).ease(.custom).to(.key(.frame, CGRect(x:20.0, y:20.0, width:280.0, height:280.0))))). .play()

Time control

Adding or animating a twin with Timeline?

It depends on what you want. The tween only animates to the desired value, taking the current value of the property as the origin, so your application can be more dynamic, any tween is destroyed once the animation is complete.

The timeline stores the values to and from each tween, contains a collection of reusable tweens, to create a timeline and add tweens, use this code :

let myTween = Timeline()

You can interact with Tmeline’s game modes, the default mode is Play Once, it will stop when you are done changing Tmeline’s game mode:

Loop, repeat forever.


Ping-Pong, back and forth.


To remove the timeline from the engine, just call stop().


Create parallax scrolling effects by manipulating the timeline with UIScrollView :

Time Inspector

You can use the timeline inspector to debug and edit tweens.

Watch the twins in real time:

Edit Gemini:


To create a timeline inspector :

let myInspector = TimelineInspector(timeline:myTimeline)


Reduce dependence on images and easily import your vector elements with PDFImageView. Forget about exporting to SVG and other formats: iO provides native PDF support with CoreGraphics, this class just renders a single pdf into a UIImageView.

How to download your asset named bee.pdf from the application :

let myAsset = PDFImageView(bundlename:bee)

You can increase or decrease the size of your assets with a single asset:

miAsset.scale = 1.5


Create more complex and impressive animations with targets


Check the movement of the tracks:


let myPathAim = PathAim(target:myAsset)
myPathAim.path = myBezierPath

To change the position on a pad, change this property:

myPadAim.interpolation = 0.5

And only a live interpolation of the tracks:

.from(.key(.interpolation, 0.0))
.to(.key(.interpolation, 1.0))

You can export your paths in code from Illustrator with this simple script:


Any kind of live rotation

let myRotationAim = RotationAim(target:myView)

.from(.key(.angle, 90.0))
.to(.key(.angle, 360.0))


Create an arc animation

let myArcAim = ArcAim(target:myView)

myArcAim.radius = 100.0

.from(.key(.arcAngle, 0.0))
.to(.key(.arcAngle, 360.0))


Animated text transitions

let stringAim = StringAim(target:myUILabel, keyPath:UILabel.text)
stringAim.from = hello
stringAim.to = hola

//Define initial interpolation
stringAim.interpolation = 0.0

/Animation with timeline for eternal replay/

/Make an intermediate with a StringAim target and an animated interpolation.
.from(.key(.interpolation, 0.0))
.to(.key(.interpolation, 1.0))
.onComplete { self.swapText() }


Play with everything, combine different types of targets:


View all transitions and timing in real time.

Create a TweenVisualizer and link it to the Tweener update loop:

let visualizer = TweenVisualizer()
visualizer.center = viewController.view.center

/Add to UIView

To disconnect the renderer from the refresh cycle, just use this code:


You can also resize the viewer by dragging, dropping and resizing it by simply dragging the bottom right corner :

This library was created to add dynamics to the elements of the user interface. If you want to create more complex animations, I recommend implementing them with Lottie.


Download requests are welcome!
The next version will include: SwiftUI examples, examples of clocks and TVs, and unit tests.




Privacy settings,How Search works,spring animation swift github

You May Also Like

Fix Not Getting Ultra HD 4K or Videos Not Showing on Netflix

Netflix offers Ultra HD (UHD) 4K games for your viewing pleasure. With…

CRED’s inbuilt library for using Neumorphic components with swift

Summary Synth is the library integrated in CRED for using neuromorphic components…

Chromecast with Google TV – Price, Specs, & Setup Guide

In September 2020, Google officially unveiled its new streaming device Chromecast with…

A Complete Guide to Solving Access Is Denied Error in Windows 10

The denial of access is quite common on Windows 10, and many…