Is it possible to use NSMutableAttributedString with SKLabelNode?

I am trying to change kerning to a pair of SKLabelNodes. I tried using some kind of code from another answer:

NSMutableAttributedString *attributedString;
attributedString = [[NSMutableAttributedString alloc] initWithString:@"Please get wider"];
[attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(10, 5)];
[self.label setAttributedText:attributedString];

This is not allowed:

[myLabelNode setAttributedText:attributedString];

And this does not tolerate the changes I made:

myLabelNode.text = attributedString.string;

Can kerning be changed to SKLabelNode?

+3
source share
1 answer

Starting with iOS 11, NSAttributedStrings are supported in SKLabelNode. Thus, kerning and other options will now be available to you.

0
source

All Articles