Swift Tutorial : How to Create a CustomTabbar or Side Menu with One Common Code Structure?

Swift Tutorial : How to Create a CustomTabbar or Side Menu with One Common Code Structure?

CustomTabbar is a common task for iOS App Developers. The look and feel of the standard tabbar in iOS 7+ are normal and good, but it doesn’t suit every time into the app’s design.

Nowadays, customizing tabbar is much easier than it was before, as Apple offers multiple simple ways to change the design of the tabbar: changing the background images, tint color, icons or text attributes offer many different ways to create a unique tabbar.


It is quite difficult to manage UI/UX. But with CustomTabbar, iOS developers can easily manage UI/UX. CustomTabbar is easy to manage than default tab bar.

Step 1: How to integrate ATTabbar.swift?

It’s simple, you just have to drag and drop “ATTabbar.swift” class in your project.

Step 2: How to Use ATTabbar.swift?

2.1 First, you have to create a “ViewController.swift” class

2.2 Now, assign it to a UIViewController in Storyboard and assign class ViewController (refer given image.)

How to Use ATTabbar.swift?

2.3 After that, you have to add “Container” in ViewController in

@IBOutlet weak var container: UIView!

Step 3: In the next step, you have to define view controller and a destination identifier in “ViewController.swift”

var destinationViewController:UIViewController!

var oldViewController:UIViewController!
var _viewControllersByIdentifier:NSMutableDictionary!
var destinationIdentifier:NSString!

Step 4:

In this step, we are adding four buttons in the bottom of UIViewController and give them a tag.

Swift Tutorial : How to Create a CustomTabbar

Step 5:

Now, create 4 new ViewControllers and name them “FirstViewController.swift”, “SecondViewController.swift”, “ThirdViewController.swift”, “FourthViewController.swift” and assign all them in storyboard as we have done with ViewController.

Swift Tutorial : How to Create a Side Menu

Step 6:

In this step, you have to connect all view controllers (“FirstViewController.swift”, “SecondViewController.swift”, “ThirdViewController.swift”, “FourthViewController.swift”) to “Container” in ViewController by custom Segue.

Side Menu with One Common Code Structure

Step 7:

Now, add identifiers (i.e. FirstSegue, SecondSegue, ThirdSegue, FourthSegue) for all view controllers and assign class“ATTabbar” for all.

Create a CustomTabbar in Swift


Side Menu with One Common Code Structure in Swift

Step 8:

After that, you have to create an action for tab bar button in “ViewController.swift” and connect it to all 4 buttons shown at the bottom.

//MARK:- Action For Tab Change

@IBAction func btnTabChangedClicked(sender: AnyObject) {
let button = sender as! UIButton
switch button.tag {

case 1:
self.performSegueWithIdentifier("FirstSegue", sender: nil)

case 2:
self.performSegueWithIdentifier("SecondSegue", sender: nil)

case 3:
self.performSegueWithIdentifier("ThirdSegue", sender: nil)

case 4:
self.performSegueWithIdentifier("FourthSegue", sender: nil)

self.performSegueWithIdentifier("FirstSegue", sender: nil)

// MARK: – Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
self.oldViewController = self.destinationViewController;

if((_viewControllersByIdentifier.objectForKey(segue.identifier!)) == nil){
_viewControllersByIdentifier.setObject(segue.destinationViewController, forKey: segue.identifier!)

self.destinationIdentifier = segue.identifier;
self.destinationViewController = _viewControllersByIdentifier.objectForKey(self.destinationIdentifier) as! UIViewController;


Step 9:

To load first tab ViewController, write below code in ‘ViewController.Swift’

override func viewDidLoad() {
if(self.childViewControllers.count < 1){
self.performSegueWithIdentifier("FirstSegue", sender: nil)


Create a CustomTabbar or Side Menu


You can directly download the source code by clicking following button.

Hope, you found this blog helpful to create CustomTabbar or side menu with one common code structure. Let us know if you have any queries or concern regarding CustomTabbar in swift.

From January 2016, we have started Swift App Development for all the new iOS development projects and we recommend our clients to hire swift developer for iPhone and iPad app projects. We as a front runner in the industry would recommend you for your business to deploy your own swift application with less code at iTunes.