iOS

First iOS application

First iOS application

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.

Top course recommendations for you

    Dev C++ Tutorial
    1 hrs
    Beginner
    6.3K+ Learners
    4.44  (234)
    Hashing in Java
    2 hrs
    Intermediate
    6.4K+ Learners
    4.44  (171)
    Eclipse Tutorial
    1 hrs
    Beginner
    3K+ Learners
    4.48  (134)
    NoSQL Database
    2 hrs
    Beginner
    11.8K+ Learners
    4.52  (822)
    SQL Triggers for Beginners
    1 hrs
    Intermediate
    12.7K+ Learners
    4.45  (544)
    WordPress with Docker
    1 hrs
    Beginner
    8.9K+ Learners
    4.51  (488)
    C++ Tutorial
    2 hrs
    Beginner
    48.9K+ Learners
    4.43  (2885)
    OOPs Concepts in C++
    2 hrs
    Beginner
    31.1K+ Learners
    4.43  (2082)
    Robotic Process Automation
    3 hrs
    Beginner
    13.1K+ Learners
    4.61  (713)
    Docker Swarm
    1 hrs
    Beginner
    1.7K+ Learners
    4.52  (107)