Bird
Raised Fist0
iOS Swiftmobile~20 mins

App icon and launch screen in iOS Swift - Mini App: Build & Ship

Choose your learning style10 modes available
Build: Launch Screen Setup
Create a simple launch screen and set a custom app icon for an iOS app.
Target UI
Launch Screen:
+---------------------+
|                     |
|      [App Icon]      |
|                     |
|    Welcome to App    |
|                     |
+---------------------+
Add a custom app icon image named 'AppIcon' to the asset catalog.
Create a launch screen storyboard with the app icon centered.
Add a label below the icon with text 'Welcome to App'.
Ensure the launch screen adapts to different device sizes.
Starter Code
iOS Swift
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // TODO: Setup window and root view controller
    return true
  }
}
Task 1
Task 2
Task 3
Task 4
Task 5
Solution
iOS Swift
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    window = UIWindow(frame: UIScreen.main.bounds)
    let viewController = UIViewController()
    viewController.view.backgroundColor = .white
    window?.rootViewController = viewController
    window?.makeKeyAndVisible()
    return true
  }
}

// LaunchScreen.storyboard setup:
// - Add UIImageView centered with image named 'AppIcon'
// - Add UILabel below with text 'Welcome to App'
// - Use Auto Layout constraints to center and space elements

// AppIcon asset catalog:
// - Add all required icon sizes for iOS app icon

// Project settings:
// - Set 'LaunchScreen.storyboard' as the launch screen file
// - Set 'AppIcon' as the app icon source

We set up the AppDelegate to create a window and a simple root view controller with a white background. The launch screen is designed in a storyboard named LaunchScreen.storyboard which contains an image view centered with the app icon image and a label below it. Auto Layout constraints ensure the layout adapts to different screen sizes. The app icon images are added to the asset catalog under the AppIcon set, including all required sizes for iOS. Finally, the project settings are configured to use the launch screen storyboard and the app icon set, so the app shows the custom icon and launch screen on startup.

Final Result
Completed Screen
Launch Screen:
+---------------------+
|                     |
|      [App Icon]      |
|                     |
|    Welcome to App    |
|                     |
+---------------------+
When the app launches, the launch screen appears showing the app icon centered with the welcome text below.
The launch screen automatically adjusts to different device sizes and orientations.
After launch, the main app screen with a white background appears.
Stretch Goal
Add a fade-out animation from the launch screen to the main app screen.
💡 Hint
Replicate the launch screen UI in the root view controller and use UIView animations to fade out to the main content.

Practice

(1/5)
1. What is the main purpose of the app icon in an iOS app?
easy
A. To display the app's settings menu
B. To represent the app on the home screen and App Store
C. To show a loading animation when the app starts
D. To provide user notifications

Solution

  1. Step 1: Understand what an app icon is

    The app icon is the image users see on their device's home screen and in the App Store.
  2. Step 2: Identify the purpose of the app icon

    It visually represents the app so users can recognize and open it easily.
  3. Final Answer:

    To represent the app on the home screen and App Store -> Option B
  4. Quick Check:

    App icon = app representation [OK]
Hint: App icon shows your app's picture on the device [OK]
Common Mistakes:
  • Confusing app icon with launch screen
  • Thinking app icon controls notifications
  • Believing app icon shows loading animations
2. Which file or folder is used to set the app icon images in an Xcode iOS project?
easy
A. Assets.xcassets/AppIcon.appiconset
B. Main.storyboard
C. Info.plist
D. LaunchScreen.storyboard

Solution

  1. Step 1: Identify where app icons are stored

    App icons are placed inside the Assets.xcassets folder, specifically in the AppIcon.appiconset.
  2. Step 2: Differentiate from other files

    LaunchScreen.storyboard is for launch screens, Info.plist holds app settings, and Main.storyboard is for UI layout.
  3. Final Answer:

    Assets.xcassets/AppIcon.appiconset -> Option A
  4. Quick Check:

    App icons = Assets.xcassets/AppIcon.appiconset [OK]
Hint: App icons live in Assets.xcassets, not storyboard files [OK]
Common Mistakes:
  • Choosing storyboard files for app icons
  • Confusing Info.plist with icon storage
  • Not knowing Assets.xcassets purpose
3. Given the following code snippet in an iOS app project, what will the launch screen display when the app starts?
/* LaunchScreen.storyboard contains a centered image named 'LaunchImage' */
// No code changes to launch screen
medium
A. The image named 'LaunchImage' centered on the screen
B. A blank white screen
C. The app icon displayed full screen
D. An error because launch screen needs code

Solution

  1. Step 1: Understand launch screen storyboard setup

    The LaunchScreen.storyboard has a centered image named 'LaunchImage'. This storyboard is shown while the app loads.
  2. Step 2: Predict what appears on launch

    Since the storyboard shows the image centered, the launch screen will display that image centered on the screen.
  3. Final Answer:

    The image named 'LaunchImage' centered on the screen -> Option A
  4. Quick Check:

    Launch screen storyboard shows its content [OK]
Hint: Launch screen shows storyboard content, no code needed [OK]
Common Mistakes:
  • Thinking launch screen shows app icon automatically
  • Assuming launch screen is blank without code
  • Believing launch screen requires Swift code
4. You set a launch screen storyboard but when running the app, the launch screen shows a black screen instead of your design. What is the most likely cause?
medium
A. The app's Info.plist is missing
B. The app icon images are missing
C. The storyboard file has syntax errors in Swift code
D. The launch screen storyboard is not assigned in the project settings

Solution

  1. Step 1: Check launch screen assignment

    If the launch screen storyboard is not set in the project settings under 'Launch Screen File', the app shows a black screen on launch.
  2. Step 2: Rule out other causes

    Missing app icons or Info.plist issues do not cause black launch screens. Storyboards do not contain Swift code, so no syntax errors apply.
  3. Final Answer:

    The launch screen storyboard is not assigned in the project settings -> Option D
  4. Quick Check:

    Launch screen file must be set in project [OK]
Hint: Always assign launch storyboard in project settings [OK]
Common Mistakes:
  • Confusing app icon issues with launch screen problems
  • Expecting Swift code in storyboard files
  • Ignoring project settings for launch screen
5. You want your app to show a launch screen with a background color and a centered logo image. Which steps correctly set this up in Xcode?
hard
A. Write Swift code in AppDelegate to display the image and background color on launch
B. Add the logo image to Assets.xcassets and set it as the app icon; no storyboard needed
C. Create a LaunchScreen.storyboard with a view colored as background and an image view centered; assign this storyboard in project settings
D. Set the background color and image in Info.plist under launch screen keys

Solution

  1. Step 1: Design launch screen in storyboard

    Create a LaunchScreen.storyboard file with a view that has the desired background color and add an image view centered with the logo image.
  2. Step 2: Assign launch screen storyboard in project

    In Xcode project settings, set the 'Launch Screen File' to this storyboard so the system shows it on app launch.
  3. Final Answer:

    Create a LaunchScreen.storyboard with a view colored as background and an image view centered; assign this storyboard in project settings -> Option C
  4. Quick Check:

    Launch screen = storyboard design + project assignment [OK]
Hint: Use storyboard for launch screen design, assign in settings [OK]
Common Mistakes:
  • Trying to set launch screen via Info.plist
  • Confusing app icon with launch screen setup
  • Attempting to use Swift code for launch screen UI
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard