I’m using NSTimer (5 second duration) with selector to select randomly name from NSArray.
Here is some code
….
NSDate *endtime = [NSDate dateWithTimeIntervalSinceNow:5];
[NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(selectPlayer:)
userInfo:endtime
repeats:YES ];
…
-(void)selectPlayer:(NSTimer *)timer
{
if ([timer.userInfo timeIntervalSinceNow] < 0)
{
[timer invalidate];
}
NSString *playerName = [[NSString alloc]initWithFormat:@"%@",
[self.playersNames objectAtIndex:random() & [self.playersNames count]-1]];
self.playersLabel.text = playerName;
[playerName release];
}
That code works pefectly. self.playersLabel is populated with random name every 0.2 seconds.
What I want is to add some fadein/fadeout animation effect while the names are changed in playersLabel.
How to achieve that ?
you can use this for setting the text: