---
title: "#218: High Performance Animated GIFs with Gifu 🚶🏻🏃🏻"
url: https://littlebitesofcocoa.com/218-high-performance-animated-gifs-with-gifu
author: Jake Marsh
published: 2016-03-23
topics: ["Libraries","UIKit"]
description: "GIFs are amazing. They make us laugh, cry, and are the medium of choice for cat owners worldwide. 🐱 Unfortunately, GIFs can also be a bit of a headache when..."
---

# #218: High Performance Animated GIFs with Gifu 🚶🏻🏃🏻

By Jake Marsh, March 23, 2016. HTML: https://littlebitesofcocoa.com/218-high-performance-animated-gifs-with-gifu

<img src="http://www.catgifpage.com/gifs/318.gif" style="max-width: max-width: 200px; float: right; margin-left: 20px; margin-bottom: 20px;"/>

_GIFs_ are amazing. They make us laugh, cry, and are the medium of choice for cat owners worldwide. 🐱

Unfortunately, _GIFs_ can also be a bit of a headache when it comes to performance. Imagine an **iOS app** that displays a vertically scrolling list of animated _GIFs_. Making sure each of those _GIFs_ is properly scaled, animating smoothly and handling memory well can be trickier than you might think.

Today we'll check out a library from [Reda Lemeden](https://github.com/kaishin) called [Gifu](https://github.com/kaishin/gifu) that aims to provide a high performance solution for this.

``` swift
let imageView = AnimatableImageView(frame: CGRect.zero)
imageView.animateWithImage(named: "cat.gif")
```

It's that simple! Under the hood, _AnimatableImageView_ uses **CADisplayLink**. It will keep the current frame, as well as the next few frames in memory, ensuring we're good memory citizens. It ends up looking like this:

<img src="https://camo.githubusercontent.com/e4331454b371dc73a79e491f43e1b9ef987eb031/68747470733a2f2f64622e74742f5a4c667832336867" style="max-width: 300px;" />

[Gifu](https://github.com/kaishin/gifu) also provides a few **functions** (`startAnimatingGIF`, `stopAnimatingGIF`, and `isAnimatingGIF`) for controlling the actual animation. Nice.

More info about _Gifu_ can be found at [git.io/gifu](http://git.io/gifu)
