Question

I want a flashing animation, Alpha value through UIView the code below, why disappear when the animation display has a direct emerged? Animation is not smooth.

[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionRepeat animations:^{
        if (aView.alpha == 0) {
            [aView setAlpha:0.5];
        }else if (middle.alpha == 0.5){
            [middle setAlpha:0];
        }
} completion:^(BOOL finished) {

}];
Était-ce utile?

La solution

When doing a repeating animation, you can often produce a more graceful animation if you use UIViewAnimationOptionAutoreverse when using UIViewAnimationOptionRepeat.

By adding the autoreverse option, that prevents the jarring UI that results otherwise, where it gracefully animates from the starting state to the end state, but then jumps back to the starting state before repeating the process. By using UIViewAnimationOptionAutoreverse, it gracefully animates back to the start state before repeating the animation.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top