Class

SKLabelNode

A graphical element that draws text.

Declaration

@interface SKLabelNode : SKNode

Overview

SKLableNode allows you to render text in your scene. You can define a custom style using properties such as fontName and fontColor, or configure the look of your text with an NSAttributedString.

Topics

Getting Started with Labels

Adding Text to a Scene

Draw text in your scene, such as a health indicator or a "Game Over" banner, by using a label node.

Creating a Label

- initWithFontNamed:

Initializes a new label object with a specified font.

+ labelNodeWithFontNamed:

Initializes a new label object.

+ labelNodeWithText:

Initializes a new label object with a text string.

+ labelNodeWithAttributedText:

Initializes a new label object with an attributed text string.

Setting a Label's Text

text

The string that the label node displays.

attributedText

The attributed string displayed by the label.

Specifying a Label's Font

fontColor

The color of the label.

fontName

The font used for the text in the label.

fontSize

The size of the font used in the label.

Controlling a Label's Alignment

verticalAlignmentMode

The vertical position of the text within the node.

SKLabelVerticalAlignmentMode

Options for aligning text vertically.

horizontalAlignmentMode

The horizontal position of the text within the node.

SKLabelHorizontalAlignmentMode

Options for aligning text horizontally.

Defining a Label's Line-Breaking Behavior

Configure these properties to control line-breaking behavior.

preferredMaxLayoutWidth

The width, in screen points, after which line-break mode should be applied.

lineBreakMode

Determines the line-break mode for multiple lines.

numberOfLines

Determines the number of lines to draw.

Colorizing a Label

color

An alternative to the font color that can be used for animations.

colorBlendFactor

A floating-point value that describes how the color is blended with the font color.

Configuring Alpha Blending

Change how a label uses an alpha value, such as additive blending, that results in the label being brighter than it was before.

blendMode

The blend mode used to draw the label into the parent’s framebuffer.

Relationships

Inherits From

See Also

Nodes that Draw

Maximizing Node Drawing Performance

Structure your nodes for maximum performance.

SKSpriteNode

An image or solid color.

SKShapeNode

A mathematical shape that can be stroked or filled.

SKEmitterNode

A source of various particle effects.

SKVideoNode

A graphical element that plays video content.

SKTileMapNode

A two-dimensional array of images.

SK3DNode

3D SceneKit content drawn as a flattened sprite.