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?
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With