UIButton flashing animation

后端 未结 5 2117
粉色の甜心
粉色の甜心 2021-02-03 15:20

I was wondering if it was possible to apply a flashing animation to a UIButton. I have searched but only found the code for a pulse animation which changes the size of my UIButt

5条回答
  •  遇见更好的自我
    2021-02-03 15:38

    Reading all the answers so far I found following solution. It repeats a number of times and does the job for me.

    CGFloat oldAlpha = v.alpha;
    CGFloat minAlpha = 0.2;
    enum UIViewAnimationOptions options = UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionCurveEaseInOut;
    
    [UIView animateWithDuration:.3 delay:0.3 options:options animations:^{
        [UIView setAnimationRepeatCount:4];
        v.alpha = minAlpha;
    }
    completion:^(BOOL finished) {
        v.alpha = oldAlpha;
    }];
    

提交回复
热议问题