I have a CAAnimation
that uses a timing function. I need callbacks to happen consistently thought the animation. Similar to jQuery's step callback. I have scoured the internet for a solution to this but have not been able to find one. (maybe I am not searching correctly)
My code thus far:
CABasicAnimation *rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:rotation / 180.0 * M_PI];
rotationAnimation.duration = duration;
rotationAnimation.repeatCount = 0;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[_image.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
I know the delegate has these two methods:
– animationDidStart:
– animationDidStop:finished:
It would be nice if there was a way to create a category to implement an
- animationProgress:
Or something similar. Or maybe CAAnimations
aren't the solution.
How can I achieve this with CAAnimations
or any alternative?
CABasicAnimation *basicAnimation=[CABasicAnimation animationWithKeyPath:<AnimatableProperty>];
CALayer *layerToAnimate=[CALayer layer];
[CATransaction begin];
[CATransaction setCompletionBlock:^{
//Stuff to be done on completion
}];
[layerToAnimate addAnimation:basicAnimation forKey:@"myCustomAnimation"];
[CATransaction commit];
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