UIPresentationController and attendant clases for iOS to present a view
controller pinned to an edge of the screen like an action sheet.
To use SheetPresentation with the
Swift Package Manager, add it as a
dependency to your project from within Xcode or as a dependency in your
To use SheetPresentation with CocoaPods, add a
dependency to your
target 'MyAwesomeApp' do pod 'SheetPresentation' end
pod install and use the generated
.xcworkspace to open your
To use SheetPresentation with
Carthage, add a dependency to your
carthage update to build the framework. Then follow the rest of the steps
in Carthage’s README to
add the framework to your project, configure a Run Script build phase, etc.
To use SheetPresentation, create a
set it as the
transitioningDelegate of the view controller you want to
present, then set the
modalPresentationStyle of the view controller to
let manager = SheetPresentationManager() // Save this reference somewhere let viewControllerToPresent = … viewControllerToPresent.transitioningDelegate = manager viewControllerToPresent.modalPresentationStyle = .custom present(viewControllerToPresent, animated: true, completion: nil)
To get the most out of SheetPresentation, you’ll need to set some options on
The corner options specify whether and how the corners of presented views should have their corners rounded:
.roundAllCorners, which takes a
CGFloatcorner radius, rounds all corners with the given radius.
.roundSomeCorners, which takes a
CGFloatcorner radius and a
CACornerMaskto specify which corner(s) should be rounded.
.noneleaves the presented view’s corners around.
The default value is
.roundAllCorners with a radius of 10 points.
SheetPresentation can place a black dimming view behind the presented view. To
control its opacity, you can specify a
CGFloat value. If you specify
then a dimming view will not be placed behind the presented view and touches
will be forwarded to the presenting view controller if they fall outside the
The default value is 50% opacity.
The edge insets control the distance between the presenting view controller and
the presented view. You can use either
NSDirectionalEdgeInsets. This value is combined with the safe area, so if
you use an inset that is less than the safe area, the safe area’s inset will be
The default value is 20 points on all sides.
You can specify an array of edges to ignore for margins (including the safe
area) when performing layout. Edges can be either the
FixedViewEdge type, depending on if you want to use
The default value is an empty array to ignore no edges.
The presentation layout controls how SheetPresentation positions the presented
view within the presentation container. Specify both horizontal and vertical
layouts, which can either be
.fill to fill the container or
automatically size the presented view. The automatic layouts must specify either
vertical or horizontal alignment to control where the presented view is placed
relative to the container.
The default value is a vertical layout of
.automatic(.bottom) and a horizontal
To correctly compute the height of the presented view controller when using
automatic layouts, it must either satisfy Auto Layout constraints for a height
or have a non-zero
When the presented view controller is presented or dismissed, these options
control the way that this animation occurs. You can use
.system to use the
default UIKit animations, use
.custom to provide your own animator objects
that conform to the
UIViewControllerAnimatedTransitioning protocol, or
.present to slide the view controller to or from the given view edge(s).
The default value is
|Last commit: 17 weeks ago|