diff --git a/PanModal/Controller/PanModalPresentationController.swift b/PanModal/Controller/PanModalPresentationController.swift index 11fb2a6e..63655eb9 100644 --- a/PanModal/Controller/PanModalPresentationController.swift +++ b/PanModal/Controller/PanModalPresentationController.swift @@ -345,7 +345,7 @@ private extension PanModalPresentationController { in the presentation animator instead of here */ containerView.addSubview(presentedView) - containerView.addGestureRecognizer(panGestureRecognizer) + presentedView.addGestureRecognizer(panGestureRecognizer) if presentable.showDragIndicator { addDragIndicatorView(to: presentedView) diff --git a/Sample/SampleViewController.swift b/Sample/SampleViewController.swift index 9cad56ba..9965fbf8 100644 --- a/Sample/SampleViewController.swift +++ b/Sample/SampleViewController.swift @@ -8,8 +8,29 @@ import UIKit +/// Allow touches to go through containerView which `isUserInteractionEnabled` is false. +private class HitTestView: UITableView { + weak var hitTestDelegateView: UIView? + + override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + if let delegateView = hitTestDelegateView, delegateView.superview != nil { + if let view = delegateView.hitTest(convert(point, to: delegateView), with: event) { + return view + } + } + + return super.hitTest(point, with: event) + } +} + class SampleViewController: UITableViewController { + private let hitTestView = HitTestView() + + override func loadView() { + self.tableView = hitTestView + } + override func viewDidLoad() { super.viewDidLoad() setupView() @@ -54,7 +75,9 @@ class SampleViewController: UITableViewController { return } dismiss(animated: true, completion: nil) - presentPanModal(rowType.presentable.rowVC) + let vc = rowType.presentable.rowVC + hitTestView.hitTestDelegateView = vc.view + presentPanModal(vc) } } diff --git a/Sample/View Controllers/User Groups/UserGroupViewController.swift b/Sample/View Controllers/User Groups/UserGroupViewController.swift index e06ad5c5..8a5ae958 100644 --- a/Sample/View Controllers/User Groups/UserGroupViewController.swift +++ b/Sample/View Controllers/User Groups/UserGroupViewController.swift @@ -106,6 +106,9 @@ class UserGroupViewController: UITableViewController, PanModalPresentable { return false } + let panModalBackgroundColor: UIColor = .clear + let isUserInteractionEnabled: Bool = false + func shouldPrioritize(panModalGestureRecognizer: UIPanGestureRecognizer) -> Bool { let location = panModalGestureRecognizer.location(in: view) return headerView.frame.contains(location)