如何使场景完全伸展到宽度。附上我的 Xcode 模拟器的截图,它没有填满屏幕

How to make the scene stretch out fully to the width. Screenshot attached of my Xcode simulator of it not filling the screen

enter image description here

import UIKit
import SpriteKit
import GameplayKit

class GameViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let view = self.view as! SKView? {
            // Load the SKScene from 'GameScene.sks'
            if let scene = SKScene(fileNamed: "MenuScene") {
                // Set the scale mode to scale to fit the window
                scene.scaleMode = .aspectFill
                
                
                // Present the scene
                view.presentScene(scene)
            }
            
            view.ignoresSiblingOrder = true
            
            view.showsFPS = false
            view.showsNodeCount = false
        }
    }

    override var shouldAutorotate: Bool {
        return true
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        if UIDevice.current.userInterfaceIdiom == .phone {
            return .allButUpsideDown
        } else {
            return .all
        }
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }
}

那是我的游戏视图控制器场景中的代码。我已经在 scene.scale 模式下尝试了 aspect fill/fit 但两者都没有任何区别。感谢您的帮助。

再次发生这种情况是因为 Apple 错误地从 iOS-only SpriteKit 游戏模板中删除了启动屏幕(它仍然存在于多平台模板中)。您需要添加和分配启动屏幕或选择主屏幕作为您的启动屏幕。

启动屏幕定义了应用程序的工作区域,因此如果没有它,视图边界和场景缩放模式将无法解决此问题。

伙计,这真的会继续成为困扰人们的问题。 Apple 的疏忽!

更多信息见