Book Image

Swift by Example

By : Giordano Scalzo
Book Image

Swift by Example

By: Giordano Scalzo

Overview of this book

Table of Contents (15 chapters)

Put the cards on the table

Finally, let's add the card images and implement the entire game.

Adding the assets

Now that everything works, let's create a nice UI again.

First of all, let's import all the assets into the project. There are plenty of free cards assets on the Internet, but if you are lazy, I've prepared for you a complete deck of images ready for this game, and you can download them from

The archive contains an image for the back of the cards, and all the front images for the others. To include them in the app, select the image assets file from the project structure view, as shown in this screenshot:

After selecting the catalogue, the images can be dragged into Xcode, as in the following screenshot:

In this operation, you must pay attention and ensure that you move all the images from 1x to 2x. Otherwise, when you run the app, you will see them pixelate.

The CardCell structure

Let's go ahead and implement...