Make SKScene fill the entire screen with Swift

I have the following in GameViewController.swift

class GameViewController: UIViewController {

    override func viewWillLayoutSubviews() {
        var skView:SKView = self.view as SKView
        if skView.scene == nil {
            skView.showsFPS = false
            skView.showsNodeCount = false

            // Create and configure the scene.
            var scene : SKScene = GameScene(size: skView.bounds.size)
            scene.scaleMode = SKSceneScaleMode.AspectFill

            // Present the scene.

    override func prefersStatusBarHidden() -> Bool {
        return true


it prints:



How do I GameScene

fill the entire screen and not leave black bars at the top and bottom of the screen?

code in GameScene.swift

class GameScene: SKScene {
    override func didMoveToView(view: SKView) {
        /* Setup your scene here */
        var background : SKSpriteNode = SKSpriteNode (imageNamed: "background.png")
        background.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2)



is a size image 640x1138

Deployment target - iOS 7.1

I am using Xcode 6.0.1 (beta)


source to share

2 answers

I had to manually add a set of images named LauchImage

in Images.xcassets




You need to resize the background node to fit your scenario.

background.size = self.frame.size




All Articles