Interactive gesture-driven animations in your iOS app (in Swift)

Introducing Interpolate

Roy Marmelstein
Swift and iOS Writing

--

In a recent (excellent) talk at try! Swift, Adam Bell argued that we should bring back the magic iOS apps lost when the world abandoned skeumorphism. I couldn’t agree more.

Magic on iOS often comes in the shape of interactive gesture-driven animations. There’s something incredible about seeing the action on the screen respond perfectly to your touch. Do you remember your reaction to inertial scrolling the first time you saw it? to the old version of Twitter for iPad? to 53’s Paper?

Remember this?

Interactive gesture-driven animations are hard work and usually involve interpolating different types of values following a gesture’s progress. I wanted to make it simpler…

Hello Interpolate

Interpolate is a new Swift interpolation framework for creating interactive gesture-driven animations. Here’s an example of it in action:

The 🔑 to Interpolate is — all animation is the interpolation of values over time. A movement is just an interpolation from one CGPoint to another, a color change is an interpolation between two UIColors etc.

Interpolate is able to interpolate a wide range of types (more are coming). To use, just create an Interpolate object, give it a from value and a to value and apply it to the target view in a closure.

All you then need to do is to get a progress value from your gesture recognizer and provide it to the Interpolate object. That’s it. The code looks like this:

Interpolate is not just for dull linear interpolations. For smoother and richer animations, Interpolate supports the following functions out of the box- EaseIn, EaseOut, EaseInOut and Spring. You can even supply your own Interpolation functions (via a protocol).

Let’s build some magical apps…

Check it out on:

github.com/marmelroy/Interpolate

--

--