I’d like to make an endless animation (e.g. making a view to move between two positions endlessly)
I wonder if this is a recursion and whether it would cause stack to overflow?
pesudo code:
-(void)doAnimation {
[UIView animateWithDuration:1.0
delay:0.0
options:(UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction)
animations:^{
if(view is at Position A){
set frame to Postion B;
}else{
set frame to Positon A;
}
}
completion:^(BOOL finished){
[self doAnimation];
}
];
}
Thanks in advance
Leo
This is the wrong way to perform a repeating animation. Look at the animation options
UIViewAnimationOptionRepeatandUIViewAnimationOptionAutoreverseinstead (documentation, see Constants at the end) Your animation could be rewritten as follows:Assuming your view starts at position A.