Stop an infinite repeating UIView block animation

Imagine you have a repeating animation created with the UIView block animation method and you want to stop.

So your creation looks like this:

[UIView animateWithDuration:2.0 delay:0.0 
    [myImageview setAlpha:1.0];
}completion:^(BOOL finished){

You can just stop this animation by  commiting a fast animation to the final value you want to have, in my case alpha 0

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.1];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
[myImageview setAlpha:0.0];
[UIView commitAnimations];


source that didn’t work for me, as first guess because I am using an UIImageView:

Leave a Reply

Your email address will not be published. Required fields are marked *