I’m using Xcode 12.5.1 and creating a new iOS Game project with SpriteKit:
- File
- New project
- iOS, Game
- Language: Swift, Game Technology: SpriteKit
Running it without any modification on the iOS simulator (e.g. "iPhone 12 mini") leads to this screen:
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:
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:
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
If I had to guess, it looks like it could be due to dark/light mode. If the app uses a
window
in theAppDelegate
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:
Also if you have a physical device then try changing the light and dark mode to see if this causes the issue
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
from the Project Navigator (⌘1).
This should resolve the issue, however you may need to update the game scene a little to account for the change in aspect ratio.