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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.