I've been playing around with drawing a path using a CAShapeLayer as outlined in this great article, http://oleb.net/blog/2010/12/animating-drawing-of-cgpath-with-cashapelayer, but I'm wondering if there's a way to animate the filling of a layer.
For example, I have some text I want to draw on the screen, but I've only been able to draw the stroke of the text and not the fill. Another example, I have a star shape that I would like to animate it being filled in.
Is this possible using a CAShapeLayer or other object?
Thanks!
Best Answer
Its most of the time the same code, you just have to set different values for
fromValue
andtoValue
of yourCABasicAnimation
. I created a category which returns me aCABasicAnimation
:Animation for StrokeEnd
Animation for fillColor
The returned
CABasicAnimation
just has to be added to aCAShapeLayer
: