Friendly Introduction iOS Animations

Mohawk Duck likes animations too

Today we’re going to go over basic animations in iOS. Animations are a great way to add a nice feeling of customisation and interactivity in your apps and there are lots of things we can do with them. In this lesson, we’ll cover some of the basics so you can get started.

Animations follow a simple pattern: From -> To with a duration. What do I mean? Well we declare what we want the view, or whatever we’re animating to go from and then we animate to.

Let’s take an example. Let’s say we want an image to animate in some way within our app. I won’t cover changing the sizes or constraints here, but I’ll introduce you to the animate API.

UIView.animate(withDuration: 1.0, animations: {

Here we have access to a static method called UIview.animate(withDuration). What’s a static method? It is a method that exists on the UIView class that we can access very conventionally by simply writing UIView. The most basic implementation comes with a duration and an animations closure.

Whenever you write animations inside the closure these will be executed over 1.0 seconds. You can lengthen and shorten these values to suit your needs.

I hope this super short introduction to animations gets you interested in the animate API with iOS. Stay tuned for more!