Our first iOS application will display a well-designed and well-known greeting to iPhone users, namely, Hello World.
A storyboard will be used to develop this application. After completing this app, you'll better understand how to utilise a storyboard to construct an iOS app. You will not impose constraints on the Views in this project for the sake of clarity, as they will be discussed in the latter portion of this tutorial, i.e., Auto Layout in Swift.
The next window will appear when you open the main storyboard from the project navigator.
The widgets from the media library can now be dragged and dropped.
ViewControllers are the fundamental components of any iOS application. Any iOS project starts with a View Controller in the storyboard and a View Controller class, such as ViewController.swift. You can add UIViews to this ViewController and program the Views in the corresponding class file by constructing outlets.
If you look at the requirements for this app, you have to display the iOS user a decorative message that says Hello World. We'll take the steps below in this iOS Tutorial to do this:
Step 1: In the storyboard, add an UiView to the ViewController
To add a UIView to the ViewController, tap the Command Shift L short key to open the media library. Search for UIView and drag the result to the ViewController's storyboard.
In the storyboard, this will add a UIView to the ViewController
Step 2: In the storyboard, add a UILabel to the ViewController.
Now, from the media files, add a UILabel to the ViewController in the storyboard.
In the media library, look for UILabel and drag the result to the Storyboard.
The Storyboard will now have a label.
Step 3: Make the UILabel more appealing.
Now we'll use the Attribute inspector to customise the UILabel with some attributes.
We'll use the same backdrop colour as the View in this project. The label will have a custom font applied to it, and it will be placed in the centre. We'll also update the UILabel's text to Hello World, as displayed in the next window.
The UILabel's properties can be viewed in the Feature inspector. In the window's left pane, the View Controller scene is displayed, along with the hierarchy of Views used in the storyboard.
To execute the project, use Command R on your keyboard. This will launch the simulator and allow you to run the code. In macOS, the simulator simulates the iPhone. In XCode, there are a variety of simulators for running iOS applications on macOS. The iPhone XR is selected by default in XCode to run the iOS app.