Simplified iOS

  • Home
  • About
  • Contact
  • Advertise
  • Write for Us

Tab Bar iOS Swift Tutorial – Working with Tab Bar in Xcode 9

March 20, 2018 by Belal Khan 2 Comments

Welcome guys to Tab Bar iOS Swift Tutorial. Many of you might already be aware of the Tab Bar. It is a very useful component to give the user a good experience of our application. Let’s say if our application has 3,4 screens then user can use this Tab Bar to navigate between the screens. You can see a Tab Bar in the below image.

tab bar ios swift

Tab Bar iOS Swift

I am pretty sure that you all have seen this Tab Bar in many applications. So now let’s learn how you can implement this thing in your own iOS Project. And trust me it is extremely easy to do. So let’s start guys.

Tab Bar iOS Swift Tutorial

  • First we will create a new Xcode Project.

creating project tab bar ios swift

  • Now from the next screen, this time we will select a Tabbed App. We were only selecting Single View Application in all the previous tutorials, but this time we need to go with Tabbed App.

tabbed app

  • Then, hit next and in the next screen fill the application name.

my tabbed app

  • Now save this project anywhere in your system.
  • This time in your project you will see two ViewControllers are created by default, namely FirstViewController.swift and SecondViewController.swift.

Tabbed Application

  • These are nothing but the normal view controller that will be switched by clicking on the Tabs. By default we have two tabs when we create a project using Tabbed App. You can add as many tabs as you want.
  • But for now open Main.storyboard and see what is there.

Tabbed View Controller

  • You can see we have a Tab Bar Controller here, and in the Tab Bar Controller we have our FistViewController and SecondViewController already attached.
  • You can execute your project now and you will see the Tabs.
Tabbed Application Example

Tabbed Application Example

  • You can see how easy it is to create Tabs.

Adding New Tab in Tab Bar

  • We actually did nothing yet. So the point is how we can add more Tabs in the Tab Bar. This thing is also very simple. In your Main.storyboard you just need to drag a new ViewController.
Dragging View Controller

Dragging View Controller

  • Just Drag the ViewController to the storyboard.

added view controller

  • You can see now we have one more View Controller in our storyboard. Now the only thing remaining is we need to connect this View Controller with our Tab Bar.
  • To do this, you need to click on the first yellow button above the Tab Bar Controller. Then press control button and drag it to the new ViewController.

relationship segue

  • Now, you will see a black pop up. From this option you need to click on view controllers, which is inside Relationship Seague.
  • And then your work is done.
Tab Bar iOS Swift Tutorial

Tab Bar iOS Swift Tutorial

  • You can see the ViewController is connected to Tab Bar. Now if you run the application you will see the third tab.

Tab Bar iOS Swift

 

  • So you can see it is working fine. The ViewControllers are the normal ViewControllers, you can add buttons, labels and other components on the ViewControllers to make whatever you want.

So that is all for this Tab Bar iOS Swift Tutorial friends. If you are having any confusions feel free to leave your comments. If you found this post helpful, then please SHARE it with your friends. Thank You 🙂

Share this:

  • Tweet
  • Share on Tumblr
  • WhatsApp

Related

Filed Under: iOS Development Tutorial Tagged With: tab bar ios swift

About Belal Khan

I am Belal Khan, I am currently pursuing my MCA. In this blog I write tutorials and articles related to coding, app development, iphone etc.

Comments

  1. Michael says

    July 13, 2018 at 2:22 am

    Thanks for this tutorial.

    Can you show persisting data between viewcontrollers related to a tab controller?

    For example, I’m using Firestore data and need to persist the userId and (for example) appointment Doc id through each controller
    let uid = myData.uid
    let apptId = myData.apptId

    Is there a limitation to how many viewcontrollers I can pass this data too?

    Michael

    Reply
  2. Rasid khan says

    July 19, 2018 at 9:54 am

    please explain how to add tab bar controller in existing project

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *




About Me

belal khan simplified ios

Hello I am Belal Khan, founder and owner of Simplified iOS. I am currently pursuing MCA from St. Xavier's College, Ranchi. Apart from my academic I am a blogger, I run various websites and majority of them are about coding and development.

Connect with Me

Follow Simplified iOS

Simplified iOS

Popular Posts

  • Swift SQLite Tutorial for Beginners – Using… (99,380)
  • Swift PHP MySQL Tutorial – Connecting iOS App… (98,248)
  • UIWebView Example to Load URL in iOS using Swift in Xcode (79,974)
  • Download Full High Sierra Installer to Create Bootable USB (70,273)
  • Xcode Login Screen Example using Swift 3, PHP and MySQL (67,256)
  • How to Format USB on Mac? Formatting External Hard… (61,373)
  • Swift JSON Tutorial – Fetching and Parsing… (59,402)
  • Firebase Realtime Database Tutorial for Swift using Xcode (53,697)
  • iOS Registration Form Example using PHP and MySQL (48,915)
  • Xcode Text Field Tutorial for iOS Application using Swift (41,145)




About

Simplified iOS is a blog where you can find latest tutorials related to coding and app development for iphone and MAC OS. Here you can get Simplified iPhone, iPad and Mac OS development tutorial to know the things about Apple Development from basics to advanced level.

Quick Links

  • Advertise
  • Contact
  • Disclaimer
  • Privacy Policy
  • Write for Us

Copyright © 2017 · Simplified iOS· All rights Reserved. And Our Sitemap.All Logos & Trademark Belongs To Their Respective Owners·