Chapter 14. Put it on my tab: creating tab bars
This chapter covers
- Using Tab Bar Controllers
- Creating tab bars
- Adding labels to tabs
You use a Tab Bar Controller every time you use the phone app on your iPhone, although you probably didn’t know what it was called until now. The tab bar is the bar at the bottom of many apps that has several buttons with icons on it. For example, in the Phone app, you have bottom icons for Favorites, Recents, Contacts, Keypad, and Voicemail. Tab Bar Controllers are powerful and allow for attractive and smooth navigation through your app.
The easiest way to learn about Tab Bar Controllers is to create an app so you can see them in action. Let’s do that now, starting with pseudocode as usual:
- Create a new app called TabBarControllerExample, using the Single View Application template.
- Delete the existing scene.
- Add a Tab Bar Controller to the storyboard and set it as the main interface.
- Add labels to the different tabs and change the tab attributes.
- Add a third tab to the app.
Let’s get started.
Create a new app in Xcode, and call it TabBarControllerExample. Make sure to use the Single View Application Template. Notice that there’s a Tabbed Application template, but you need to understand how the Tab Bar Controller works from a high level first.