O'Reilly logo

Learning Swift™ Programming by Jacob Schatz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Buttons and Labels

Now that you’ve prepared pictures, it’s time to display them as UI elements that players can see and select. You can add a Game Status label and Reset button, too, though these elements aren’t linked to images. Start by navigating to Main.storyboard in the Xcode project inspector. You should see the blank canvas where you’ll place your grid. Locate the search bar in the bottom-right corner of the editor and type in UI Image View. Xcode returns a result, which you can drag and drop onto the main workspace.

Stretch the UIImageView until it fills the screen. After you’ve resized the element, click it and look for the Attributes inspector in the upper-right corner. Be sure to uncheck the User Interaction Enabled option under ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required