UIView animations with autoreverse

前端 未结 3 1646
梦谈多话
梦谈多话 2020-12-12 18:44

I have a problem with the setting UIViewAnimationOptionAutoReverse. Here is my code.

CALayer *aniLayer = act.viewToChange.layer;
[UIView animate         


        
3条回答
  •  半阙折子戏
    2020-12-12 19:23

    Here's my solution. For 2x repeat, animate 1.5x and do the last 0.5x part by yourself:

    [UIView animateWithDuration:.3
                          delay:.0f
                        options:(UIViewAnimationOptionRepeat|
                                 UIViewAnimationOptionAutoreverse)
                     animations:^{
                         [UIView setAnimationRepeatCount:1.5f];
    
                         ... animate here ...
    
                     } completion:^(BOOL finished) {
                             [UIView animateWithDuration:.3 animations:^{
    
                                 ... finish the animation here ....
    
                             }];
                     }];
    

    No flashing, works nice.

提交回复
热议问题