Blinking effect on UILabel
You can do this within a block:
self.yourLabel.alpha = 1;[UIView animateWithDuration:1.5 delay:0.5 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations:^{ self.yourLabel.alpha = 0;} completion:nil];
So you dont need a second method.
Swift 3
extension UILabel { func startBlink() { UIView.animate(withDuration: 0.8, delay:0.0, options:[.allowUserInteraction, .curveEaseInOut, .autoreverse, .repeat], animations: { self.alpha = 0 }, completion: nil) } func stopBlink() { layer.removeAllAnimations() alpha = 1 }}
Use NSTimer
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(1.0) target:self selector:@selector(blink) userInfo:nil repeats:TRUE];BOOL blinkStatus = NO;
in your blink function
-(void)blink{ if(blinkStatus == NO){ yourLabel.backgroundColor = [UIColor whiteColor]; blinkStatus = YES; }else { yourLabel.backgroundColor = [UIColor grayColor]; blinkStatus = NO; }}