Skip to content

Commit

Permalink
pin modal size to inset container
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Nystrom committed Oct 9, 2019
1 parent 6bae31e commit 846252c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ContextMenu/ContextMenuPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ class ContextMenuPresentationController: UIPresentationController {

override var frameOfPresentedViewInContainerView: CGRect {
guard let containerBounds = containerView?.bounds else { return .zero }
let size = presentedViewController.preferredContentSize
var size = presentedViewController.preferredContentSize

// cap size to inset container bounds
size.width = min(containerBounds.width - 2 * item.options.containerStyle.edgePadding, size.width)
size.height = min(containerBounds.height - 2 * item.options.containerStyle.edgePadding, size.height)

let frame: CGRect
if let corner = preferredSourceViewCorner {
let minPadding = item.options.containerStyle.edgePadding
Expand Down

0 comments on commit 846252c

Please sign in to comment.