iPhone - UIView Animation not looping correctly
- by Robert
Hey all, got a little problem here and can't figure out what I am doing wrong. I am trying to animate a UIView up and down repeatedly. When I start it, it goes down correctly and then back up but then immediately shoots to the "final" position of the animation. Code is as follows:
UIImageView *guide = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
guide.frame = CGRectMake(250, 80, 30, 30);
[self.view addSubview:guide];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:2];
[UIView setAnimationRepeatAutoreverses:YES];
[UIView setAnimationBeginsFromCurrentState:YES];
guide.frame = CGRectMake(250, 300, 30, 30);
[UIView setAnimationRepeatCount:10];
[UIView commitAnimations];
Thanks in advance!