Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flickering for multiple concurrent calls to UIView transitionWithView with UIViewAnimationOptionTransitionCrossDissolve on UIImageView

I would like to animate the change of an image to another from a UIImageView with:

[UIView transitionWithView:self.scrollView
                      duration:1
                       options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction
                    animations:^
    {
        self.imageView.image = image;

    } completion:nil];

which works perfectly fine for one animation. But if I have one or more animations starting while the first one is still in progress I get some wired behavior it looks like some sort of jumps or flickering. If I use slow animations in the simulator it seems the first animation is stopped and jumps right to the end image of the first animation and starts then with the second one. Does anyone have an idea how to prevent this to happen?

like image 953
BObereder Avatar asked Dec 29 '25 01:12

BObereder


1 Answers

Try to tell the animation that it should begin from the current state. (UIViewAnimationOptionBeginFromCurrentState)

[UIView transitionWithView:self.imageView
                      duration:1
                       options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionAllowUserInteraction 
                    animations:^
    {
        self.imageView.image = image;

    } completion:nil];
like image 106
sust86 Avatar answered Dec 30 '25 17:12

sust86



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!