Creating a UI for the app

We will now create some UI-like buttons for hosting and joining a session and a Map button to send the map once we have connected to a peer. We will also create a couple of text labels to tell us what the app is doing currently.

For sending the map, we will create a custom class so that the button lights up when the map is ready to be sent.

Create a new Swift file called RoundedButton. In it, create a new class of the same name and inherit from UIButton:

import UIKit

@IBDesignable
class RoundedButton: UIButton {

    
}

In this class, we will add the init function, which will, in turn, call the setup() function in which we will set the button parameters.

Also, override the isEnabled function, which, when set, will change backgroundColor ...

Get Swift Game Development - Third Edition now with O’Reilly online learning.

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