How to make a shape draw itself with strokeEnd

As we learned in a previous post, iOS makes it super simple to draw shapes using CAShapeLayer. By playing with the strokeStart and strokeEnd properties you can make shapes draw themselves on the screen. You can draw really cool shapes like a crescent or half-drawn star.

But whats really cool is the ability to animate the drawing process on the screen.

First, let’s create our shape

then let’s create our animation using CABasicAnimation

And there you have it!