Adding a View to our View Controller in the Storyboard

In this section, we will take a look at how we can use Views to act as a means of defining places where we need to present content differently than standard views allow. The advantage of creating custom views is that they allow you to handle interactions with any object that is added to that interface, which you can use to animate things quite easily.

Let's start adding a View object to our View Controller by performing the following steps:

  1. Ensure the SlidingTiles solution is currently open in the Visual Studio for Mac IDE.
  2. Then, from the Toolbox Library, drag a View control onto the View Controller.
  3. Next, resize the View control so that it fills the width of the View Controller and matches the width of the Label control that we added previously:
Adding a View within the View Controller

  1. Then, select the View control in the View Controller to bring up the Properties window and ensure that the Widget tab has been selected, as shown in the following screenshot:
Modifying the properties for the View control
  1. Next, from the Properties window, modify the Name property, which is located in the Identity section, to read gameBoardView.
  2. Then, set the Content Mode property to be Scale To Fill, and set the Background property to be Dark Gray Color.
  3. Next, select the View control in the View Controller to bring up the Properties window and select the Layout tab, as shown in the following screenshot:
Updating Layout properties for the View control
  1. Then, modify the X property to read 20 and the Y property to read 102, which are located in the View section.
  2. Next, modify the Width property to read 374 and the Height property to read 335, which are located in the View section.

Excellent, the user interface for our Sliding Tiles game is coming along quite nicely; we have added a Label control as well as a View control. Before we proceed with adding the remaining controls to our View Controller in our Storyboard, it would be good to save our Storyboard. Our next step is to add a Button control to our View Controller, which will reset the game in progress.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.66.156