I am pretty much sure that for this can't be used NSMutableAttributedString and NSAttributedString. What I've tried is:
NSMutableAttributedString * newString = [[NSMutableAttributedString alloc] initWithString:@"firstsecondthird"];
[newString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,5)];
[newString addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(5,6)];
[newString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(11,5)];
labelNode.text = [newString string];
This doesn't work and text still has it's original color. Is there any way to do this with SKLabelNode ? Using multiple SKLabelNodes is solution, but I can't say it's elegant (or performant).
I found something that may interest you on GitHub. It's in Swift but code is very short and should be easily comprehensible.
ASAttributedLabelNode
SKLabelNode does not support NSAttributedString or NSMutableAttributedString. When you use labelNode.text = [newString string] you're taking just the text portion of the attributed string and ignoring all of the changes you made in the previous lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With