Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to detect a running animation in iOS?

I'm trying to find a way to detect if a view is being animated.

Case in point: I have applied a shadow on the layer of a view, specifying a shadowPath for performance. When the view is resized, the shadow should animate along. I can observe the frame of the view, and change the shadowPath of the layer accordingly. But while the view is resizing, the shadow jumps ahead since the change is not animated.

I know how to animate the shadowPath using a CABasicAnimation, but I need to know the properties of an ongoing animation so that I can apply them to my animation as well (mostly: duration, easing).

This is in a framework-type component, so I just cannot assume I know the duration and easing properties on beforehand.

Is there a way to detect a starting/running animation when observing the frame?

like image 752
Inferis Avatar asked Jan 14 '12 23:01

Inferis


1 Answers

You can retrieve all animations attached to particular view's layer knowing it's key by calling

[yourView.layer animationForKey:@"key"]

to get all keys there is some animation for, call

NSArray* keys = [yourView.layer animationKeys];
like image 178
gavrix Avatar answered Nov 18 '22 16:11

gavrix