Skip to content

Commit 846252c

Browse files
author
Ryan Nystrom
committed
pin modal size to inset container
1 parent 6bae31e commit 846252c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ContextMenu/ContextMenuPresentationController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ class ContextMenuPresentationController: UIPresentationController {
5858

5959
override var frameOfPresentedViewInContainerView: CGRect {
6060
guard let containerBounds = containerView?.bounds else { return .zero }
61-
let size = presentedViewController.preferredContentSize
61+
var size = presentedViewController.preferredContentSize
62+
63+
// cap size to inset container bounds
64+
size.width = min(containerBounds.width - 2 * item.options.containerStyle.edgePadding, size.width)
65+
size.height = min(containerBounds.height - 2 * item.options.containerStyle.edgePadding, size.height)
66+
6267
let frame: CGRect
6368
if let corner = preferredSourceViewCorner {
6469
let minPadding = item.options.containerStyle.edgePadding

0 commit comments

Comments
 (0)