hi all ! Does anyone know how to make a UILabel appear letter by letter like you can see in some games or other.
thanks
hi all ! Does anyone know how to make a UILabel appear letter by letter like you can see in some games or other.
thanks
Set up an NSTimer to set the text property of the UILabel.
-(void) revealTimer:(NSTimer *)inTimer {
if ( ++mIndex < [mFullString length] ) {
mLabel.text = [mFullString substringToIndex:mIndex];
} else {
mLabel.text = mFullString;
[inTimer invalidate];
}
}
start it up with something like this:
-(void) revealString:(NSString *)inString {
mIndex = 0;
mLabel.text = "";
mFullString = [inString retain];
[NSTimer scheduledTimerWithTimeInterval:0.125 target:self selector:@selector(revealTimer:) userInfo:nil repeats:YES];
}
be sure not to leak mFullString as the above does, and store the timer if you may need to invalidate it.