File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Sources/DeclarativeLayoutKit/Chaining/Actions Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // UIGestureRecognizer+Action.swift
3+ //
4+ //
5+ // Created by uuttff8 on 13.07.2021.
6+ //
7+
8+ import UIKit
9+
10+
11+ /// Add action to a UIGestureRecognizer.
12+ ///
13+ /// Using:
14+ ///
15+ /// UIView()
16+ /// .addGesture(gesture: UITapGestureRecognizer()
17+ /// .addAction {
18+ /// // ...
19+ /// })
20+ extension UIGestureRecognizer {
21+ func addAction( _ action: @escaping ( ) -> Void ) -> Self {
22+ let action = ClosureAction ( attachTo: self , closure: action)
23+ self . addTarget ( action, action: ClosureAction . selector)
24+ return self
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -34,4 +34,9 @@ public extension UIView {
3434 addGestureRecognizer ( UILongPressGestureRecognizer ( target: action, action: ClosureAction . selector) )
3535 return self
3636 }
37+
38+ func addGesture< Gesture: UIGestureRecognizer > ( overwrite: Bool = false , gesture: Gesture ) -> Self {
39+ addGestureRecognizer ( gesture)
40+ return self
41+ }
3742}
You can’t perform that action at this time.
0 commit comments