I need my image view to change its .image at the beginning and end of each animation.
This is the animation:
- (void)performLeft{
CGPoint point0 = imView.layer.position;
CGPoint point1 = { point0.x - 4, point0.y };
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position.x"];
anim.fromValue = @(point0.x);
anim.toValue = @(point1.x);
anim.duration = 0.2f;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
// First we update the model layer's property.
imView.layer.position = point1;
// Now we attach the animation.
[imView.layer addAnimation:anim forKey:@"position.x"];
}
I know that I could call...
[anim animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)];
But I don't know how I could use an animation to change the image of imView
?
So how do I use an animation to change the .image
of my image view?
Thank you!