【发布时间】:2015-08-04 19:42:31
【问题描述】:
我很确定不能使用 NSMutableAttributedString 和 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 是一种解决方案,但我不能说它很优雅(或高效)。
【问题讨论】:
标签: objective-c sprite-kit nsattributedstring sklabelnode