Well, you need to set up an array of points as a property of the class, something like animationPath . So, now you will need to pay attention to the delegate methods of the UIView animation delegation methods (this is not a completely different class, it is just a delegate of class methods).
Set the way you call setAnimationDidStopSelector:selector every time the animation stops, so here you have something like this:
//Inside the callback for setAnimationDidStopSelector if ([animationPath count] != 0){ //Go to next point CGPoint location = [[self.array objectAtIndex:0] CGPointValue]; [UIView animateWithDuration:0.1 animations:^{ self.imageView.center = location; } completion:^(BOOL finished){ }]; } else{ NSLog(@"Nowhere else to go, animation finished :D"); }
So just remember to start the animation with the first point.
As far as I remember, the UIView animation manages things in other threads, so this is probably why the for statement doesn't work.
source share