6.5. Placing Images and Other UI Components on Storyboards

Problem

You want to be able to place images, buttons, and other UI components onto your storyboard files.

Solution

Use the Object Library in Interface Builder to look for various UI components. When you are ready to place them on your storyboard files, simply drag and drop them. You can then use the Attributes Inspector to configure those components.

Discussion

Let’s say that you want to place some images on your storyboard. In Interface Builder, while you have your storyboard file open, hold down Ctrl+Alt+Command+3 on your keyboard to get to the Object Library. In the Object Library, find the Image View component (Figure 6-16) and drag and drop it onto your main view controller. Now press Alt+Command+4 simultaneously on your keyboard to open the Attributes Inspector. In this panel, you can now configure your image view. To add an image to this image view, simply add that image to your project. From the Attributes Inspector, while your image view is selected, set its image property, as shown in Figure 6-17.

Every now and then, you may find yourself in a situation where you just cannot find the right UI component in the Object Library but you are sure that the component exists. I know that I have been in that situation. The Object Library gives you a really nice search box where you can just type the name of the component that you are interested in. To get to the search box, make sure that you have already selected the Object Library ...

Get iOS 7 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.