December 2016
Intermediate to advanced
416 pages
15h 21m
English
The first UIGestureRecognizer subclass you will use is UITapGestureRecognizer. When the user taps the screen twice, all of the lines on the screen will be cleared.
Open TouchTracker.xcodeproj and DrawView.swift. Add an init?(coder:) method and instantiate a UITapGestureRecognizer that requires two taps to fire and calls the action method on its target.
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let doubleTapRecognizer = UITapGestureRecognizer(target: self,
action: #selector(DrawView.doubleTap(_:)))
doubleTapRecognizer.numberOfTapsRequired = 2
addGestureRecognizer(doubleTapRecognizer)
}
Now when a double-tap occurs on an instance of DrawView, the method
Read now
Unlock full access