Blinking effect on UILabel

前端 未结 14 1934
野的像风
野的像风 2020-12-13 14:24

I have a UILabel with background color as grey.

I want a blinking effect on this label like it should become a little white & then become gray and it should keep

14条回答
  •  离开以前
    2020-12-13 15:03

    -(void) startBlinkingLabel:(UILabel *)label 
    {
        label.alpha =1.0f;
        [UIView animateWithDuration:0.32
                              delay:0.0
                            options: UIViewAnimationOptionAutoreverse |UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction |UIViewAnimationOptionBeginFromCurrentState
                         animations:^{
                             label.alpha = 0.0f;
                         }
                         completion:^(BOOL finished){
                             if (finished) {
    
                             }
                         }];
    }
    
    -(void) stopBlinkingLabel:(UILabel *)label 
    {
        // REMOVE ANIMATION
        [label.layer removeAnimationForKey:@"opacity"];
        label.alpha = 1.0f;
    }
    

提交回复
热议问题