Home > Articles > Home & Office Computing > Entertainment/Gaming/Gadgets

  • Print
  • + Share This
This chapter is from the book

One More Thing: Interface Builder and Tab Bar Controllers

Xcode offers easy-to-customize tab bar instances that gets you started building tab-bar-based GUIs in Interface Builder. By default, this object creates two child view controllers in the storyboard. You can expand this basic presentation by adding new view controllers to the tab bar controller and/or setting classes using the identity inspector (see Figure 5-9).

Figure 9 (Click to Enlarge) Interface Builder storyboards provide tools for laying out tab bar controllers, simplifying laying out what is essentially a logical and not a visual class than previous versions of Xcode allowed.

You’ll likely want to create a new view controller class for each tab, to allow each tab to offer a separate and meaningful function. To add art to the tabs in IB, drag 20x20 png images from the Library > Media pane onto each tab button, as shown mid-drag in Figure 5-10, or set the art using the tab bar item's attribute inspector. The Media pane lists the images you have added to your Xcode project. Design your images using a transparent background and a white foreground.

Figure 10 (Click to Enlarge) Drag art from the media library directly onto the tab bar item shown below each child view controller.

Interface Builder's new storyboards offer a friendly way to both lay out individual view controllers and connect them to their parents. This is a vast change from previous versions of Xcode, where many developers found themselves forgoing IB to design and deploy tab bars and navigation bars in code.

  • + Share This
  • 🔖 Save To Your Account