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
int count;
NSTimer *timer;
timer= [NSTimer
scheduledTimerWithTimeInterval:(NSTimeInterval)(0.5)
target:self
selector:@selector(animationStart)
userInfo:nil
repeats:TRUE];
-(void)animationStart{
switch (count) {
case 0:
//205 198 115
count++;
lbl.textColor=[UIColor colorWithRed:205.0f/255.0f green:198.0f/255.0f blue:115.0f/255.0f alpha:1];
break;
case 1:
count++;
//205 198 115 56 142 142
lbl.textColor=[UIColor colorWithRed:56.0f/255.0f green:142.0f/255.0f blue:142.0f/255.0f alpha:1];
break;
case 2:
count++;
//205 198 115
lbl.textColor=[UIColor colorWithRed:205.0f/255.0f green:205.0f/255.0f blue:0.0f/255.0f alpha:1];
break;
case 3:
count++;
//205 198 115 84 255 159
lbl.textColor=[UIColor colorWithRed:84.0f/255.0f green:255.0f/255.0f blue:159.0f/255.0f alpha:1];
break;
case 4:
count++;
//205 198 115 255 193 37
lbl.textColor=[UIColor colorWithRed:255.0f/255.0f green:193.0f/255.0f blue:37.0f/255.0f alpha:1];
break;
case 5:
count++;
//205 198 115 205 200 177
lbl.textColor=[UIColor colorWithRed:205.0f/255.0f green:200.0f/255.0f blue:117.0f/255.0f alpha:1];
break;
case 6:
count++;
//205 198 115 255 228 181
lbl.textColor=[UIColor colorWithRed:255.0f/255.0f green:228.0f/255.0f blue:181.0f/255.0f alpha:1];
break;
case 7:
count++;
//205 198 115 233 150 122
lbl.textColor=[UIColor colorWithRed:233.0f/255.0f green:150.0f/255.0f blue:122.0f/255.0f alpha:1];
break;
case 8:
count++;
//205 198 115 233 150 122
lbl.textColor=[UIColor colorWithRed:255.0f/255.0f green:200.0f/255.0f blue:200.0f/255.0f alpha:1];
break;
case 9:
count=0;
//205 198 115 255 99 71 255 48 48
lbl.textColor=[UIColor colorWithRed:255.0f/255.0f green:48.0f/255.0f blue:48.0f/255.0f alpha:1];
break;
default:
break;
}
}
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.