Swift Animation Club — Part 1

Eyup Göymen
Sep 1, 2018 · 3 min read

Hi Swift lovers, It’s a nice day to start an animation series. In this one, I am just going to cover some basic animations including changing color, movement, etc with UIView animation. Next, in the other stories, we are going to make some animations that is eyes on the eye. Let’s jump coding…


Before we start, please create a any view or simply use mine. Please do not forget to add circle view as a subview of controller’s view.


UIView Animation

We have basically four types of function with different parameters:

1- Two Parameters (time, animation block)

The first one is simple, it has only two parameters including closure for animation block and duration for animation. And this method use curveEaseInOut option (We will mention it in other posts of the series). It looks like:

Basically, you can just define a duration and animation. Let’s make an example for it. So, we have a nice orange circle in the middle of the screen. Let’s change color if it.

And you will see tiny color change:

2- With Completion Block

In this one, we have one extra option that is called right after the animation ends. This method use curveEaseInOut option as well.

In that completion block, you can make another animation too. We simply add another method to the completion block. Let’s move that circle right, then move it to the origin.

3- With Delay and Option

We have new parameters and option. I prefer to explain option later on in depth. Delay provides us time lag for animation. It is simply like:

What it does is starting animation after waiting for four seconds and applying the animation. I don’t think, we need to make an example for that one. It’s almost same as the previous one. Try to make own animation with that. It’s all about your imagination!

4- Spring Animation

This one is the most professional one that provides an acceleration option for us. Also, we have other parameters including the all parameters that I covered so far.

usingSpringWithDamping property increases/decreases the acceleration where as initialSpringVelocity defines initial velocity of the animation.

Let’s try to move our pretty ugly circle to right and see the difference with the other methods.

The best way to under stand the spring is trying the all remarkable value intervals by one by 🤙🏼


Okey guys we are done with first part. Stand by for the nice and cool animations more. As I said, this one was introducing the swift animations. In the next one, I am going to cover animation options in depth. I’ll see you.


If you like our publication and want to join us check this out: tinyurl.com/jointowhoknows

WHOKNOWS

We produces contents about iOS / Swift development.

Eyup Göymen

Written by

WHOKNOWS

WHOKNOWS

We produces contents about iOS / Swift development.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade