Onglo
Onglo

Reputation: 191

How to make a SKLabelNode's text centre left

I have seen that to make a UILabel's text align to different sides you can use

yourLabel.textAlignment

However, I am creating a game in SpriteKit and do not have this option on an SKLabelNode. My question is how can I align the text left on an SKLabelNode?

Upvotes: 1

Views: 150

Answers (1)

septicorn
septicorn

Reputation: 142

For an SkLabelNode, horizontalAlignmentMode changes whether the text is centered on the node's origin, the text is on the left side node's origin, or the text is on the right side of node's origin.

So you can do label.horizontalAlignmentMode = .right to align the text to the left.

There is more information on this here.

Upvotes: 1

Related Questions