Circular animation to display UIImageView

I have a โ€œcircularโ€ image, something like a pie chart. I would like to get a nice animation, for example, when a pie chart fills from 0 to a value.

I usually use something like this when I want to animate views:

[UIView animateWithDuration: 3.0 delay: 0.0 options: UIViewAnimationCurveEaseInOut animations: ^ { // The animation } completion: ^(BOOL finished) { // On completion } ]; 

Is it possible to do the same thing for circular animation? I really don't know how to do this.

Thanks for any links!

Note: iOS 5, storyboards, ARC and all that :)


Edit: for future discussion, the image looks like this:

enter image description here

+4
source share
2 answers

Ok, here it is :)

The first option (simple). You can use the UIImageView animationImages property. Make an NSArray with animated images (in your case, circular images fill from 0 to full circle), set animationDuration and call [imageView startAnimating] (I assume your UIImageView is equal to imageView ) and you can call [imageView stopAnimating] when the process is complete.

Secondly: Look at this link http://www.cocoacontrols.com/platforms/ios/controls/jpradialactivityindicator , I think the sample project does almost the same thing you are trying to do :)

Good luck;)

+3
source

1) You can use CAShapeLayer

  • You can achieve this by revitalizing the strokeStart and strokeEnd properties. You can create a path for a full circle and use the strokeStart and strokeEnd properties to stroke only a specific part of the circle.

2) You can also refer to this guide: Animating Pie Slices Using Custom CALayer

Good luck !!!

+2
source

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


All Articles