我很确定不能为此使用NSMutableAttributedString
and NSAttributedString
。我试过的是:
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];
这不起作用,文本仍然具有原始颜色。有什么办法可以做到这一点SKLabelNode
吗?使用多个SKLabelNodes
是解决方案,但我不能说它是优雅的(或高性能的)。