Swiftgram/submodules/TouchDownGesture/Sources/TouchDownGestureRecognizer.swift
2019-08-10 02:34:03 +03:00

26 lines
796 B
Swift

import Foundation
import UIKit
import UIKit.UIGestureRecognizerSubclass
public class TouchDownGestureRecognizer: UIGestureRecognizer, UIGestureRecognizerDelegate {
public var touchDown: (() -> Void)?
override public init(target: Any?, action: Selector?) {
super.init(target: target, action: action)
self.delegate = self
}
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
override public func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
super.touchesBegan(touches, with: event)
if let touchDown = self.touchDown {
touchDown()
}
}
}