---
title: "#106: EasyAnimation 🏃"
url: https://littlebitesofcocoa.com/106-easyanimation
author: Jake Marsh
published: 2015-10-19
topics: ["Animation","UIKit","Libraries"]
description: "Animation is one of the greatest parts about building (and using) iOS apps. The APIs however, can feel a bit scattered."
---

# #106: EasyAnimation 🏃

By Jake Marsh, October 19, 2015. HTML: https://littlebitesofcocoa.com/106-easyanimation

_Animation_ is one of the greatest parts about building (and using) **iOS** apps. The **APIs** however, can feel a bit scattered. **UIView's** animation **functions** are wonderful, but some animations require using **Core Animation** directly.

When they do, things get progressively more complex depending on if we need to run multiple animations in succession, or just run code after an animation completes.

Today we'll look at a great library from [Marin Todorov](https://github.com/icanzilb) called [EasyAnimation](https://github.com/icanzilb/EasyAnimation) that improves on all of this. Let's dive in: 

_EasyAnimation_ makes animating **CALayers** that normally would require **CABasicAnimation** (or one of its siblings) work with the standard `UIView.animateWithDuration` **functions**:

``` swift
UIView.animateWithDuration(0.3, animations: {
  self.view.layer.position.y = 64.0
})
```

Under the hood, _EasyAnimation_ does all the heavy lifting of translating our animations back into **CAAnimation** code and handling all of the implementation details for us. Neat!

Normally, if we wanted to run code after one the animations on a **CALayer** finished, we'd need to wire up an animation delegate, implement the callback **functions**, make sure to clean up after ourselves, etc.

With _EasyAnimation_ though, we're able to just use the normal completion closure.

``` swift
UIView.animateWithDuration(
  0.3,
  delay: 0.1,
  options: [.BeginFromCurrentState],
  animations: {
  self.view.layer.borderWidth = 2.0
  self.view.layer.cornerRadius = 12.0
}, completion: { finished in
  self.tableView.reloadData()
})
```

Last but certainly not least, _EasyAnimation_ makes "chaining" multiple animations together (running one after another) extremely convenient. It also supports cancelling the chain, repeating, delays and more:

``` swift
let chain = UIView.animateAndChainWithDuration(0.3, animations: {
  self.avatarView.center = headerView.center
}).animateWithDuration(0.2, animations: {
  self.headerView.alpha = 1.0
})
```

More info about [EasyAnimation](http://git.io/easyanimation) can be found at [git.io/easyanimation](http://git.io/easyanimation)
