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 ...

Get Learning Swift™ Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.