Creating DrawView

In addition to a custom struct, TouchTracker needs a custom view.

Create a new Swift file named DrawView. In DrawView.swift, define the DrawView class. Add two properties: an optional Line to keep track of a line that is possibly being drawn and an array of Lines to keep track of lines that have been drawn.

import Foundation
import UIKit

class DrawView: UIView {

    var currentLine: Line?
    var finishedLines = [Line]()

}

An instance of DrawView will be the view of the application’s rootViewController, the default ViewController included in the project. The view controller needs to know that its view will be an instance of DrawView.

Open Main.storyboard. Select the View and open the identity inspector (Command-Option-3). Under Custom Class, change the Class to DrawView (Figure 18.4).

Figure 18.4  Changing the view class

Screenshot shows the identity inspector. In the Custom Class heading, two fields: Class and Module are shown. The Class is set to “DrawView.”
..................Content has been hidden....................

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