UIBezierPath - fill animation

I have a UIBezierPath (circle) built gradually:

[circlePath addArcWithCenter:clockCenter radius:radius startAngle:angleRadians endAngle:1.5*M_PI clockwise:YES]; ... [circlePath closePath]; [COLOR_CIRCLE setFill]; [circlePath fill]; 

Sometimes I would like to animate the filling so that it takes a second to completely fill and follow the path as it was built (clockwise). What is the preferred way to accomplish this? Right now I think that Core Animation, but I hope that there will be a filling: withDelay or some such that I did not stumble. TIA.

+6
source share
1 answer

You can try the following:

Create a CAShapeLayer whose path set to your form. Use this CAShapeLayer as a mask for another layer into which you draw a filled arc / circle. Then animate the angle of the arc / arc circle from 0º to 360º. This may come close to the desired effect.

I can’t find a “built-in” way to animate the fill as you wish. However, there is a built-in way to animate the stroke:

Use a UIView with a CAShapeLayer supporting it. CAShapeLayer has a path property. You can then apply the animation to the properties of the strokeStart and / or strokeEnd .

+2
source

Source: https://habr.com/ru/post/920173/


All Articles