Tab Bar Controller iOS Tutorial

The UITabBarController class implements a specialized view controller that manages a radio-style selection interface. This tab bar interface displays tabs at the bottom of the window for selecting different views. In this Tutorial a Tab Bar Controller will be created and by default two Tab Bar Items will be included. The third Tab Bar Item will be added using the Storyboard. This tutorial is made with Xcode 10 and built for iOS 12.

Open Xcode and create a new Tapped App.

For product name, use IOS12TabBarControllerTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next.

For the Tab Bar items some custom images will be used. Download the images, unzip them and add the images to the Assets Library. Go to the Storyboard. In the Document Outline select the First Bar button Item in the First Scene and go to the Attribute Inspector. In the Bar Items section change the title to "Red" and select the book image.

Repeat this step for the Second Bar Item of the Second View Controller. Name it "Blue" and select the clock image.

Select to the Red View and change the Background to red using the Attributes Inspector. In the blue view change the Background to blue. Also remove the Labels inside the view.

The Storyboard should now look like this.

Build and Run the project, and change views by clicking the Tab Bar Items.

Next, we will add another Tab Bar Item inside the Storyboard. Drag a View Controller from the Object Library to the Scene. Select the View Controller and go to the Attribute Inspector. Change the Background color to Green. Next Ctrl and Drag from inside the Tab Bar Controller to the newly created View Controller and select "view controllers" in the Relationship Segue section.

In the Document Outline select the Tab Bar Item in the Item Scene and Go to The Attribute Inspector. In the Bar Items section change the title to "Green" and select the crown image.

Build and Run the project, the 3 Tab Bar Items will be visible. By clicking the Icons the Views will change.

You can download the source code of the IOS12TabBarControllerTutorial at the ioscreator repository on Github.