A node that displays a text label.
- iOS 7.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 3.0+
Just about every game needs to display text at some point, even if it is just to display “Game Over” to the player. If you had to implement this yourself in OpenGL, it would take a fair amount of work to get it correct. But the
SKLabel class does all of the work necessary to load fonts and create text for display.
To use a label node, create a new label node by calling the
label class method. Then configure the other label properties, especially the
text property. The size of a label node is determined implicitly by the label node’s
By default, the text label is centered horizontally on the label node’s origin, with the font’s baseline passing through the origin. The
horizontal properties can be used to adjust the label’s position relative to the origin. Listing 1 demonstrates how to create a new text label.
Whenever you change the label node’s properties, the label node is automatically updated the next time the scene is rendered.