The menu screen
Let's start implementing the first view, in which we can select the level of the game.
Implementing the basic menu screen
As we have planned to implement all of the UI in the code itself, we won't bother to touch the storyboard. We will proceed to open the ViewController
class to implement the menu screen.
Looking at the mockup, we can see that we have three levels of difficulty: easy, medium, and hard. There are three buttons, each one used to select one of them. Also, the buttons are horizontally centered and vertically equidistant.
First of all, we define an enumeration to describe the difficulty.
Then, we implement the setup for the layout:
enum Difficulty { case Easy, Medium, Hard }
Just for the sake of readability, we group the methods needed to implement a feature in a separated extension, leaving in the main class only the public functions and the variable definition. Although extensions were born for a different goal, which is to extend classes we don't have the source...