iOS Launch Screen (Splash Screen)

  Total Views : 129
  Comments : 0
 
  Keywords : Add splash screen to ios app in swift with example, How to add launch screen image to ios app in swift application with example, Show launch screen while loading ios app in swift

Here we will learn iOS launch screen or splash screen in swift with example and how to set or add launch screen to ios swift applications with example using xcode.

iOS Launch Screen (Splash Screen)

In iOS launch screen or splash screen will appear instantly while launching our app and it will replace immediately with the home screen of our app. The main purpose of iOS launch / splash screen is to let user know that app is loading and the launch screen will disappear quickly once our application loading is completed.

 

Generally, the iOS launch / split screen will cover complete screen and it’s better to mention your brand details as an image like as shown below.

 

iOS Launch Screen Sample Examples

 

It’s better to use launch / splash screen for all the apps even if it takes less time to launch main screen.

iOS Launch / Splash Screen Sizes

As we discussed launch screen / splash screen will cover complete screen so the launch screen size will vary based on the apple devices. To solve this problem, we need to provide images with different sizes for different devices. Following table shows the image sizes required for different devices.

 

DevicePortrait sizeLandscape size
iPhone 6s Plus, iPhone 6 Plus 1080px x 1920px 1920px x 1080px
iPhone 6, iPhone 6s 750px x 1334px 1334px x 750px
iPhone SE 640px x 1136px 1136px x 640px
12.9-inch iPad Pro 2048px x 2732px 2732px x 2048px
9.7-inch iPad Pro, iPad Air 2, iPad mini 2 / 4 1536px x 2048px 2048px x 1536px

Now we will see how to add iOS launch screen in our swift applications using Xcode storyboard with example.

Create iOS LaunchScreen App in Swift

To create new project in iOS open Xcode from /Applications folder directory. Once we open Xcode the welcome window will open like as shown below. In welcome window click on the second option “Create a new Xcode Project” or choose File --> New --> Project.

 

Xcode application to create ios project

 

After selecting “Create a new Xcode project” a new window will open in that we need to choose template.

 

The new Xcode window will contain several built-in app templates to implement common type of iOS apps like page based apps, tab-based apps, games, table-view apps, etc. These templates are having pre-configured interface and source code files. 

 

For this iOS Launch Screen example, we will use most basic template “Single View Application”. To select this one, Go to the iOS section in left side --> select Application --> In main area of dialog select “Single View Application” and then click on next button like as shown below.

 

Select single view application from ios xcode templates

 

After click Next we will get window like as shown below, in this we need to mention project name and other details for our application.

 

Product Name: “Launch Screen in iOS”

 

The name whatever we enter in Product Name section will be used for the project and app.

 

Organization Name: “Tutlane”

 

You can enter the name of your organization or your own name or you can leave it as blank.

 

Organization Identifier: “com.developersociety”

 

Enter your organization identifier in case if you don't have any organization identifier enter com.example.

 

Bundle Identifier: This value will generate automatically based on the values we entered in Product Name and Organization Identifier.

 

Language: “Swift”

 

Select language type as “Swift” because we are going to develop applications using swift.

 

Devices: “Universal”

 

Choose Devices options as Universal it means that one application is for all apple devices in case if you have any specific requirement to run app only for iPad then you can choose the iPad option to make your application restricted to run only on iPad devices.

 

Use Core Data: Unselected

 

This option is used for database operations. In case if you have any database related operations in your application select this option otherwise unselect the option.

 

Include Unit Tests: Unselected

 

In case if you need unit tests for your application then select this option otherwise unselect it.

 

Include UI Tests: Unselected

 

In case if you need UI tests for your application then select this option otherwise unselect it.

 

Once you finished entering all the options then click on Next button like as shown below.

 

ios launch screen create new app using swift in xcode

 

Once we click on Next button new dialog will open in that we need to select the location to save our project. Once you select the location to save project then click on Create button like as shown below

 

Give path to save new ios application in xcode

 

After click on Create button the Xcode will create and open a new project. In our project Main.storyboard and ViewController.swift are the main files which we used to design app user interface and to maintain source code. 

 

Main.storyboard - Its visual interface editor and we will use this file to design our app user interface 

 

ViewController.swift - It contains source code of our application and we use this file to write any code related to our app.

 

Now in project select Main.storyboard file the Xcode will open visual interface editor like as shown below.

 

ios launch screen app storyboard file in xcode

 

Now select ViewController.swift file in your project that view will be like as shown below.

 

ios launch screen app viewcontroller.swift file in xcode

 

To add launch screen image for application, we need make required configurations in LaunchScreen.storyboard file like as shown below

 

iOS launch screen storyboard in xcode

 

Now download the simple image from internet and drag the image and drop into your project like as shown below.

 

Add image to ios launch screen app project in xcode

Add iOS UI Controls to View in Swift

Now we will add controls to our application for that open Object Library. The Object Library will appear at the bottom of Xcode in right side. In case if you don't find Object library, click on the button which is at the third position from the left in the library selector bar like as shown below. (Alternatively you can choose View --> Utilities --> Show Object Library.)

 

Object Library in Xcode Application to Search for UI Controls

 

Now open LaunchScreen.storyboard file so open LaunchScreen.storyboard file. Now in Object library search for the Image View in Filter field then drag and drop Image View into LaunchScreen.storyboard and click on imageview to set the image like as shown below.

 

ios launch screen storyboard add controls

 

Now open Main.storyboard file and in Object library search for Button in Filter field then drag and drop button into Main.storyboard ViewController and click on button and give name as “Launch Screen” like as shown below.

 

ios launch screen add controls to storyboard file in xcode

 

Now we will run and check the output of application. To run application, select the required simulator (Here we selected iPhone 6s Plus) and click on Play button, located at the top-left corner of the Xcode toolbar like as shown below.

 

Run launch screen app in xcode using simulator

Output of iOS Launch Screen App in Swift

Following is the result of iOS launch screen app in swift. When we run application and if it takes long time to load our launch screen will appear like as shown.

 

ios launch screen application example result or output

 

This is how we can use ios launch screen in swift applications to show launch screen while starting of the app based on our requirements.

 

PREVIOUS

iOS App Icons
 

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User