Skip to content

Commit

Permalink
Merge pull request #269 from FelixII/ipad-dropdown-fix
Browse files Browse the repository at this point in the history
Fixed layout issue with album dropdown on iPad
  • Loading branch information
mikaoj authored Jun 29, 2020
2 parents b6e85e1 + 08aa390 commit e24aa40
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,25 @@ class DropdownPresentationController: UIPresentationController {
}

override var frameOfPresentedViewInContainerView: CGRect {
guard let containerView = containerView else { return .zero }

guard let containerView = containerView,
let presentingView = presentingViewController.view else { return .zero }

let size = self.size(forChildContentContainer: presentedViewController,
withParentContainerSize: containerView.bounds.size)
withParentContainerSize: presentingView.bounds.size)

let position: CGPoint
if let navigationBar = (presentingViewController 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)
position = CGPoint(x: 0, y: navigationRect.height + navigationRect.origin.y)
let presentingRect = presentingView.convert(presentingView.frame, to: containerView)
position = CGPoint(x: presentingRect.origin.x, y: presentingRect.origin.y + navigationRect.height)

// Match color with navigation bar
presentedViewController.view.backgroundColor = navigationBar.barTintColor
} else {
position = .zero
}

return CGRect(origin: position, size: size)
}
}

0 comments on commit e24aa40

Please sign in to comment.