GestureRecognizer
public class GestureRecognizer
Initializers
init(target:action:)
Initializes an allocated gesture-recognizer object with a target and an action selector.
public init<Target: AnyObject>(target: Target,
action: @escaping (Target) -> () -> Void)
The valid signatures for action
are:
-
(Target) -> () -> Void
aka()
-
(Target) -> (_: GestureRecognizer) -> Void
aka(_: GestureRecognizer)
Although the signature permits nullable types, the values may not be nil.
init(target:action:)
public init<Target: AnyObject>(target: Target,
action: @escaping (Target) -> (_: GestureRecognizer) -> Void)
init()
public /* convenience */ init()
Properties
delegate
The delegate of the gesture recognizer.
public weak var delegate: GestureRecognizerDelegate?
numberOfTouches
Returns the number of touches involved in the gesture represented by the receiver.
public private(set) var numberOfTouches: Int = 0
state
The current state of the gesture recognizer.
public var state: GestureRecognizer.State = .possible
view
The view the gesture recognizer is attached to.
public internal(set) var view: View?
isEnabled
A boolean property that indicates whether the gesture recognizer is enabled.
public var isEnabled: Bool = true
buttonMask
A bit mask of the button (or buttons) in the gesture represented by the receiver.
public private(set) var buttonMask: Event.ButtonMask = []
modifierFlags
Constants that indicate which modifier keys are pressed.
public private(set) var modifierFlags: KeyModifierFlags = []
name
The name associated with the gesture recognizer.
public var name: String?
Methods
addTarget(_:action:)
Adds a target and an action to a gesture-recognizer object.
public func addTarget<Target: AnyObject>(_ target: Target,
action: @escaping (Target) -> () -> Void)
The valid signatures for action
are:
-
(Target) -> () -> Void
aka()
-
(Target) -> (_: GestureRecognizer) -> Void
aka(_: GestureRecognizer)
addTarget(_:action:)
public func addTarget<Target: AnyObject>(_ target: Target,
action: @escaping (Target) -> (_: GestureRecognizer) -> Void)
removeTarget(_:action:)
Removes a target and an action from a gesture-recognizer object.
public func removeTarget<Target: AnyObject>(_ target: Target,
action: @escaping (Target) -> () -> Void)
removeTarget(_:action:)
public func removeTarget<Target: AnyObject>(_ target: Target,
action: @escaping (Target) -> (_: GestureRecognizer) -> Void)
location(in:)
Returns the point computed as the location in a given view of the gesture represented by the receiver.
public func location(in view: View?) -> Point
location(ofTouch:in:)
Returns the location of one of the gesture’s touches in the local coordinate system of a given view.
public func location(ofTouch touchIndex: Int, in view: View?) -> Point
shouldReceive(_:)
public func shouldReceive(_ event: Event) -> Bool