I want to flash an UIImageview on the iPad, how do I do that?

后端 未结 4 1933
自闭症患者
自闭症患者 2021-02-08 19:10

I want to let a UIImageView flash several times.

Currently I don\'t know how to do that.

Actual code:

-(void)arrowsAnimate{
    [UIVi         


        
4条回答
  •  被撕碎了的回忆
    2021-02-08 19:44

    There is a simpler way to achieve a flashing animation using only 1 animation block:

    aview.alpha = 1.0f;
    [UIView animateWithDuration:0.5f
                          delay:0.0f 
                        options:UIViewAnimationOptionAutoreverse
                     animations:^ {
           [UIView setAnimationRepeatCount:10.0f/2.0f];
           aview.alpha = 0.0f;
    } completion:^(BOOL finished) { 
           [aview removeFromSuperview]; 
    }];    
    

    The trick is to use [UIView setAnimationRepeatCount:NTIMES/2]; *_inside_* your animation block. No need for extra functions or extra loops.

提交回复
热议问题