Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ import UIKit
class DropdownPresentationController: UIPresentationController {
private let dropDownHeight: CGFloat = 200
private let backgroundView = UIView()
private weak var source: UIViewController?

init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?, source: UIViewController) {
super.init(presentedViewController: presentedViewController, presenting: presentingViewController)

self.source = source
setupBackgroundView()
}

override init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?) {
super.init(presentedViewController: presentedViewController, presenting: presentingViewController)

self.setupBackgroundView()
}

private func setupBackgroundView() {
backgroundView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
backgroundView.backgroundColor = .clear
backgroundView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(backgroundTapped(_:))))
Expand Down Expand Up @@ -62,7 +74,7 @@ class DropdownPresentationController: UIPresentationController {
withParentContainerSize: presentingView.bounds.size)

let position: CGPoint
if let navigationBar = (presentingViewController as? UINavigationController)?.navigationBar {
if let navigationBar = (source as? UINavigationController)?.navigationBar {
// We can't use the frame directly since iOS 13 new modal presentation style
let navigationRect = navigationBar.convert(navigationBar.bounds, to: nil)
let presentingRect = presentingView.convert(presentingView.frame, to: containerView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import UIKit

class DropdownTransitionDelegate: NSObject, UIViewControllerTransitioningDelegate {
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
return DropdownPresentationController(presentedViewController: presented, presenting: presenting)
return DropdownPresentationController(presentedViewController: presented, presenting: presenting, source: source)
}

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
Expand Down