iosswiftsprite-kitsklabelnode

SKLabelNode Creating Black Rectangle


I saw this question, but it did not have a definite solution to the issue, nor is it the exact same. I am trying to simply add a SKLabelNode with some text. I have never had issues but for some reason this is happening: Black bar is the SKLabelNode Here is the code I am using to generate the node:

var announceLabel = SKLabelNode(fontNamed: "Baskerville")
announceLabel.text = "ERROR LOADING ANNOUNCEMENT"
announceLabel.fontColor = UIColor.blackColor()
announceLabel.fontSize = 200
announceLabel.setScale(twitterButton.frame.height / announceLabel.frame.height)
announceLabel.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
self.addChild(announceLabel)

I am testing this on my iPhone 6, and I have never had this happen while creating a label node. I have attempted different fonts, positions, and scales with no effect. Any help is greatly appreciated! Thanks!


Solution

  • Just tested some more and I found the answer. The font size was too big and I guess caused a bug with SpriteKit. I changed the font size to 50 and it worked fine (I have used font size 200 on other label nodes and never had an issue):

    var announceLabel = SKLabelNode(fontNamed: "Baskerville")
    announceLabel.text = "ERROR LOADING ANNOUNCEMENT"
    announceLabel.fontColor = UIColor.blackColor()
    announceLabel.fontSize = 50
    announceLabel.setScale(twitterButton.frame.height / announceLabel.frame.height)
    announceLabel.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
    self.addChild(announceLabel)