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
; otherwise, it will be gray in color.
Add the following init
function:
override init(frame: CGRect) { super.init(frame: frame) setup() }
We also need the required init
function, so add it, as shown in the following...