I'm trying to animate the same images in a different position like this:
for (int i = 0; i == 3; i++) {
UIImageView *imageToAnimate = [[UIImageView alloc] initWithFrame: imageFrameTwo];
[imageToAnimate setImage: [UIImage imageNamed: imageTwo]];
CGPoint point0 = imageTwoImage.layer.position;
CGPoint point1 = { point0.x + 10*i, point0.y - 10*i + 50};
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"position.y"];
anim.fromValue = @(point0.y);
anim.toValue = @(point1.y);
anim.duration = 15.0f;
anim.repeatCount = HUGE_VALF;
anim.cumulative = NO;
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
// First we update the model layer's property.
imageToAnimate.layer.position = point1;
// Now we attach the animation.
[imageToAnimate.layer addAnimation:anim forKey:@"position.y"];
[theView addSubview:imageToAnimate];
}
But nothing happens. Without cycle it works well. Am I doing something wrong?