SpriteKit Project — AbsolutelyBrickingIt — Part 2: Set up a launch screen
In this article, we’re going to set up the launch screen for the project.
Adding image assets to the project
From the Project navigator (on the left side of Xcode, press ⌘0
if not visible), select Assets
:
Using Finder, select the launch screen images and drag them onto the list of assets:
The added images are now visible as an Image Set in Assets:
Adding the image to the launch screen
Select LaunchScreen
in the Project navigator (⌘0
):
Open the Object Library (⇧⌘L
) and select Image View
:
Drag and drop Image View
from the Object Library onto the ViewController in LaunchScreen:
Hold Ctrl (⌃
) and drag from Image View
to View
:
Select the follow constraints:
- Leading Space to Safe Area
- Top Space to Safe Area
- Trailing Space to Safe Area
- Bottom Space to Safe Area
Select the first constraint in the hierarchy:
In the Size Inspector on the right side of Xcode (⌥⌘6
), change Safe Area
to Superview
in one of the item drop downs:
Set the Constant to 0:
Repeat the above steps to pin each anchor to the corresponding Superview
anchor:
Select Image View
in the hierarchy:
Open the Attributes Inspector (⌥⌘5
):
Set the image to the name of the Image Set from Assets (in this case screen.launch
):
Running the project in a simulator
Click the play button in the toolbar to run the project:
The new launch screen is now visible as the app is starting up:
We’ve successfully added an image to the Launch screen that displays as the app is starting up.
Code
This article corresponds to the merge commit Add Launch screen (#2)
in the GitHub repository AbsolutelyBrickingIt