I am trying to get my animation move in more than one generated path. I got my codes down but I still don’t get what is wrong with it.
Here is where I place my image in the view
UIImageView *faceAni = [[UIImageView alloc] initWithFrame:CGRectMake(200, 100, 50.0, 50.0)];
faceAni.animationImages = faces;
faceAni.animationDuration = 10;
faceAni.animationRepeatCount = 0;
[faceAni startAnimating];
[self addSubview:faceAni];
And here is where I try to get the animation to move in a triangular path coordinates.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView animateWithDuration:4
delay:0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{faceAni.transform = CGAffineTransformMakeTranslation(0, 200);}
completion:^(BOOL finished) {
[UIView animateWithDuration:4
delay:0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{faceAni.transform = CGAffineTransformTranslate(faceAni.transform, -100, 0);}
completion:^(BOOL finished) {
[UIView animateWithDuration:4
delay:0
options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse
animations:^{faceAni.transform = CGAffineTransformTranslate(faceAni.transform, 300, 0);}
completion:NULL];
}];
}];
I still don’t get what is wrong with my codes.
Thanks in advance!
It might help if you describe the behaviour that you’re seeing. As a guess, though, you probably don’t want the
UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverseflags you’re passing to each animation.