---
title: "EasyAnimation"
slug: easyanimation
section: tech
date: 2015-06-08T12:26:00.000Z
canonical: https://roland.leth.ro/blog/tech/easyanimation
---

[This](https://github.com/icanzilb/EasyAnimation) makes usage of `UIView.animateWithDuration:animations` so much more appealing. Some examples from the repo's readme:

```swift
// Also works with spring animations:
UIView.animate(duration: 2.0, delay: 2.0, 
  options: [.repeat, .autoreverse, .curveEaseOut], 
  animations: {
    self.view.layer.position.x += 200.0
    self.view.layer.cornerRadius = 20.0
    self.view.layer.borderWidth = 5.0
}, completion: nil)
  
// Also works with chains!
UIView.animateAndChain(duration: 1.0, delay: 0.0, 
  options: nil, animations: {
    self.view.center.y += 100
}, completion: nil).animate(duration: 1.0, animations: {
  self.view.center.x += 100
}).animate(duration: 1.0, animations: {
  self.view.center.y -= 100
}).animate(duration: 1.0, animations: {
  self.view.center.x -= 100
})

// A nice addition is canceling chains:
let chain = UIView.animateAndChain(duration: 1.0, delay: 0.0,
  options: nil, animations: {
    self.square.center.y += 100
}, completion: nil).animate(duration: 1.0, animations: { ... }
[...]
// Will stop after finishing the current step in the chain.
chain.cancelAnimationChain()
```

Install via `cocoaPods` with `pod 'EasyAnimation'`.