I found this code to animate a label with a typing effect. I'm trying to adapt it for attributed strings.
https://stackoverflow.com/a/11687530/1813525
I tried this but I assume that i'm just recreating the same code based on the string of an attributed string :
- (void)animateLabelShowText:(NSAttributedString*)newText characterDelay:(NSTimeInterval)delay
{
[self.mainLabel setText:@""];
for (int i=0; i<newText.length; i++)
{
dispatch_async(dispatch_get_main_queue(),
^{
[self.mainLabel setAttributedText:[[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%C", [self.mainLabel.attributedText string], [[newText string] characterAtIndex:i]] attributes:nil]];
});
[NSThread sleepForTimeInterval:delay];
}
}
Any idea how I could preserve the formatting of my attributed text newText
Thanks for your help.