1

Is there a possibility to change the number of lines of an SKLabelNode?

Like UiLabel:

UILabel *label = [UILabel new];
label.numberOfLines = 2;
user3138007
  • 637
  • 1
  • 6
  • 19
  • 1
    The answer is no. Hopefully, that extended feature will be available with iOS 8. – El Tomato May 06 '14 at 16:59
  • I think there's a multi-line label extension node for sprite kit on github which splits a string into multiple labels on newlines. – CodeSmile May 06 '14 at 17:08

2 Answers2

3

It's possible. Just set numberOfLines + preferredMaxLayoutWidth:

let lb = SKLabelNode(fontNamed: "Courier-bold")
lb.numberOfLines = 0
lb.preferredMaxLayoutWidth = size.width
Mike Keskinov
  • 11,614
  • 6
  • 59
  • 87
1

Currently that is not possible.

You could create your own SKMultilineLabelNode class if you wanted to, and as mentioned in the comments there is an extension on github.

prototypical
  • 6,731
  • 3
  • 24
  • 34