WWDC24 SALE: Save 50% on all my Swift books and bundles! >>

Dive into Spritekit and SwiftUI does not fill whole screen

Forums > Books

I am trying to work on Project 1 and use SpriteKit and SwiftUI but for some reason the scene never fill the whole screen on my iPad.

//  ContentView.swift
//  HackingProject1
//  Created by Max on 2021-05-18.

import SwiftUI
import SpriteKit

struct ContentView: View {
    var scene: SKScene {
        let screenWidth  = UIScreen.main.bounds.width
        let screenHeight = UIScreen.main.bounds.height

        let scene = GameScene()
        scene.size = CGSize(width: screenHeight, height: screenWidth)
        scene.scaleMode = .fill
        scene.backgroundColor = .green
        return scene

    var body: some View {
        let screenWidth  = UIScreen.main.bounds.width
        let screenHeight = UIScreen.main.bounds.height


        return SpriteView(scene: scene)
            .frame(width: screenWidth, height: screenHeight)

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {

Right now it looks like this:

Any ideas what I am missing here?



Save 50% in my WWDC sale.

SAVE 50% To celebrate WWDC24, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.