Skip to content
Published November 26, 2016

Introduction

I am writing this article since I needed to create a TabBar with custom TabBarItems which have different dimensions. Surprisingly I didn’t find a method or approach to accomplish that in the official documentation or any other website.

Before we start here is the final result

screen-shot-2016-10-14-at-2-43-11-pm

custom TabItem with custom image

Getting to work

  • FIrst of all let’s launch xCode and open our project (or create a fresh app if not already existant). As soon as your project is ready, create a new Cocoa touch class like it is shown below:

ardfn

Let’s name the newly-created class CustomTabViewController (so it will be self-explanatory) and move on to the header file: CustomTabViewController.h and and past this code.

 

 

now let’s go to the implementation, go to the .m file of the class (CustomTabViewController.m) and past this code:

 

  • Setting the UITabBarController

Please node that CustomTabViewController will act as UITabBarController of our TabBar so we might as well set it as so, we can do that using the StoryBoard as it is shown below:

screen-shot-2016-10-14-at-2-47-05-pm

 

  • We are all set!

You can customize the UITabBarItem dimensions, background as you wish and however it suits you now!

 

You can find the code on GitHub!

 

Be First to Comment

Leave a Reply

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