Blinking effect on UILabel

前端 未结 14 1938
野的像风
野的像风 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 14:41

    Tweaking Krishnabhadra Answer to give a better blink effect

    Declare a Class variable bool blinkStatus;

    And paste code given below

    NSTimer *yourtimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(10.0 / 60.0)  target:self selector:@selector(blink) userInfo:nil repeats:TRUE];
        blinkStatus = FALSE;
    
    -(void)blink{
        if(blinkStatus == FALSE){
            yourLabel.hidden=NO;
            blinkStatus = TRUE;
        }else {
            yourLabel.hidden=YES;
            blinkStatus = FALSE;
        }
    }
    

提交回复
热议问题