Alexandros February 2016

Unable to draw SKLabelNode in front of UIView

I'm adding a SKLabelNode in my GameScene.swift by using the following code

 let scoreLabel = SKLabelNode(fontNamed: "GillSans-BoldItalic")
    scoreLabel.fontSize = 25
    scoreLabel.text = "Text"
    scoreLabel.position = position
    scoreLabel.zPosition = 3000
    self.addChild(scoreLabel)

However, when the label appears it is behind a UIView (that contains a couple of UIImageView elements), despite it's intentionally high .zPosition.

How can I make it appear in front of my UIView? I can't find a .zPosition equivalent on UIView.

Answers


daltonclaybrook February 2016

The zPosition only relates to other nodes within the same scene. If you have a UIView that has been added on top of your SKView that holds the scene, subviews of this view will always appear on top of nodes in your scene. Consider adding your images as nodes inside your SKView instead of in their own view.

Post Status

Asked in February 2016
Viewed 3,193 times
Voted 10
Answered 1 times

Search




Leave an answer