Recipe: Creating a Custom Gesture Recognizer
It takes little work to transform the code shown in Recipe 1-10 into a custom recognizer, but Recipe 1-11 does it. Subclassing UIGestureRecognizer
enables you to build your own circle recognizer that you can add to views in your applications.
Start by importing UIGestureRecognizerSubclass.h
from UIKit into your new class. The file declares everything you need your recognizer subclass to override or customize. For each method you override, make sure to call the original version of the method by calling the superclass method before invoking your new code.
Gestures fall into two types: continuous and discrete. The circle recognizer is discrete. It either recognizes a circle or fails. Continuous gestures ...
Get The Core iOS Developer’s Cookbook, Fifth 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.