18 Touch Events and UIResponder

In the next two chapters, you will create TouchTracker, an app that lets the user draw by touching the screen. In this chapter, you will create a view that draws lines in response to the user dragging across it (Figure 18.1). Using multitouch, the user will be able to draw more than one line at a time.

Figure 18.1  TouchTracker

Screenshot shows a detail view controller that has a drawing of an iPhone device at the center.

Touch Events

As a subclass of UIResponder, a UIView can override four methods to handle the four distinct touch events:

  • one or more fingers touch the screen

    func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
    
  • one or more fingers ...

Get iOS Programming: The Big Nerd Ranch Guide, 6th 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.