From the course: Advanced iOS App Development: Core Animation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Modifying shapes

Modifying shapes - iOS Tutorial

From the course: Advanced iOS App Development: Core Animation

Start my 1-month free trial

Modifying shapes

- So far, we've managed to animate a shaped property and move another one along a defined path. But what if we wanted to actually transform one shape into another? Well, for that, we'll need to animate the shape's path property itself, which is what we'll do with our trusty circle. We're gonna wanna squish our circle down into a square, and back into a circle as it follows the square path. Let's go down to the bottom of our script, and as usual, we'll create a new function, and we're gonna call this animateCircleShapeChange. Just like our circle by a path animation, this is gonna be a basic animation. We're gonna call this squish of type CABasicAnimation. And I don't believe we have the correct key path, so let's go into our animation helper, say static var shapePath. And the key path strength for that is just Path. Now, the circle makes its way around the square every three seconds, and I think we should have it change shape, then reverse once during that time. So lets say…

Contents