skip to Main Content

I’m using Xcode 12.5.1 and creating a new iOS Game project with SpriteKit:

  1. File
  2. New project
  3. iOS, Game
  4. Language: Swift, Game Technology: SpriteKit

Running it without any modification on the iOS simulator (e.g. "iPhone 12 mini") leads to this screen:

Screenshot of default SpriteKit app on iOS simulator (running)

This looks fine, it has black borders around the scene. However, when I swipe from the bottom to go into the Task Switcher, the black border suddenly turns into a grey/white border:

Screenshot of default SpriteKit app on iOS simulator (in task switcher)

I also tried changing the "Background" property of the "View" in Main.storyboard to black like this, which has no effect on the task switcher appearance:

Screenshot of Xcode with the background of the "View" in Main.storyboard set to "Black"

This should be easy to reproduce by just creating the default SpriteKit example app, running it on a real phone or a simulator and going into task switcher view.

I want the background of the app in the Task Switcher to be black in the task switcher view, just like when the app is running. Note that the app I’m creating has a fixed aspect ratio for the SKSpriteNode I’m using, so the solution shouldn’t involve setting a different size to the Scene. Basically it should work for any aspect ratio and letterbox my SKSpriteNode in the view with black letterboxing in both app view and app switcher view.

2

Answers


  1. If I had to guess, it looks like it could be due to dark/light mode. If the app uses a window in the AppDelegate class, try setting the background of that to .black.

    Or you can specify that your app will only work in dark mode (only do this if your app is for iOS 13+). you do this by adding this to your plist file:

    <key>UIUserInterfaceStyle</key>
    <string>Dark</string>
    

    Also if you have a physical device then try changing the light and dark mode to see if this causes the issue

    Login or Signup to reply.
  2. The game app template seems to be missing a LaunchScreen storyboard, this can cause iOS to fallback and render previews at an incorrect size in some situations. To add one you can do the following

    1. From the menu bar select File > New > File (⌘N) and select Storyboard.
    2. Name the new Storyboard "LaunchScreen.storyboard".
    3. Open your newly created LaunchScreen.storyboard file by selecting it
      from the Project Navigator (⌘1).
    4. From the Storyboard document outline select the View Controller and ensure "Is Initial View Controller" is selected in the Attributes Inspector (⌥⌘5). (See Image)
    5. From the Project Navigator (⌘1) select your Info.plist
    6. Add a new key to your Info.plist (↵) titled "Launch screen interface file base name" and set the value to "LaunchScreen".

    This should resolve the issue, however you may need to update the game scene a little to account for the change in aspect ratio.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search