Search code examples
iosswiftuicolor

How to set the text color of an SKLabelNode?


I have the following code, which doesn't seem to set the text color of scoreLabelNode to red.

func setUpScore() -> Void {
    scoreLabelNode = SKLabelNode(fontNamed:"MarkerFelt-Wide")
    scoreLabelNode.color = UIColor(red: CGFloat(1.0), green: CGFloat(0.0), blue: CGFloat(0.0), alpha: CGFloat(1.0)) //How do I set this to red?
    scoreLabelNode.position = CGPointMake( CGRectGetMidX( self.frame ), 0.5)
    scoreLabelNode.zPosition = 100
    scoreLabelNode.text = String(score)
    self.addChild(scoreLabelNode)
}

How would I change the second line to get the score to display as red?


Solution

  • Try (note the 'fontColor', not 'color')

     scoreLabelNode.fontColor = UIColor.redColor()