File tree 2 files changed +18
-6
lines changed
2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,19 @@ import UIKit
7
7
public class BackdropView : UIView {
8
8
9
9
/// The gesture recognizer for tap gestures to dismiss a panel.
10
- @objc public var dismissalTapGestureRecognizer : UITapGestureRecognizer !
10
+ ///
11
+ /// By default, this gesture recognizer is disabled as following the default behavior of iOS modalities.
12
+ /// To dismiss a panel by tap gestures on the backrdop, `dismissalTapGestureRecognizer.isEanbled` is set to true.
13
+ @objc public var dismissalTapGestureRecognizer : UITapGestureRecognizer
14
+
15
+ init ( ) {
16
+ dismissalTapGestureRecognizer = UITapGestureRecognizer ( )
17
+ dismissalTapGestureRecognizer. isEnabled = false
18
+ super. init ( frame: . zero)
19
+ addGestureRecognizer ( dismissalTapGestureRecognizer)
20
+ }
21
+
22
+ required init ? ( coder: NSCoder ) {
23
+ fatalError ( " init(coder:) has not been implemented " )
24
+ }
11
25
}
Original file line number Diff line number Diff line change @@ -96,11 +96,9 @@ class Core: NSObject, UIGestureRecognizerDelegate {
96
96
panGestureRecognizer. addTarget ( self , action: #selector( handle ( panGesture: ) ) )
97
97
panGestureRecognizer. delegate = self
98
98
99
- // Set tap-to-dismiss in the backdrop view
100
- let tapGesture = UITapGestureRecognizer ( target: self , action: #selector( handleBackdrop ( tapGesture: ) ) )
101
- tapGesture. isEnabled = false
102
- backdropView. dismissalTapGestureRecognizer = tapGesture
103
- backdropView. addGestureRecognizer ( tapGesture)
99
+ // Set the tap-to-dismiss action of the backdrop view.
100
+ // It's disabled by default. See also BackdropView.dismissalTapGestureRecognizer.
101
+ backdropView. dismissalTapGestureRecognizer. addTarget ( self , action: #selector( handleBackdrop ( tapGesture: ) ) )
104
102
}
105
103
106
104
deinit {
You can’t perform that action at this time.
0 commit comments