Swiftpack.co - Package - detroit-labs/SheetPresentation

SheetPresentation

A UIPresentationController and attendant clases for iOS to present a view controller pinned to an edge of the screen like an action sheet.

Version Documentation Carthage compatible Swift Package Manager License Platform

Installation

Swift Package Manager

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 Package.swift file.

CocoaPods

To use SheetPresentation with CocoaPods, add a dependency to your Podfile:

target 'MyAwesomeApp' do
  pod 'SheetPresentation'
end

Then run pod install and use the generated .xcworkspace to open your project.

Carthage

To use SheetPresentation with Carthage, add a dependency to your Cartfile:

github "Detroit-Labs/SheetPresentation"

Run 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.

Using SheetPresentation

Swift

To use SheetPresentation, create a SheetPresentationManager and set it as the transitioningDelegate of the view controller you want to present, then set the modalPresentationStyle of the view controller to .custom.

let manager = SheetPresentationManager() // Save this reference somewhere
let viewControllerToPresent = …
viewControllerToPresent.transitioningDelegate = manager
viewControllerToPresent.modalPresentationStyle = .custom

present(viewControllerToPresent, animated: true, completion: nil)

Objective-C

SheetPresentation also works with Objective-C:

SheetPresentationManager *manager = [[SheetPresentationManager alloc] init];

UIViewController *viewControllerToPresent = …;
viewControllerToPresent.transitioningDelegate = manager;
viewControllerToPresent.modalPresentationStyle = UIModalPresentationCustom;

[self presentViewController:viewControllerToPresent
                   animated:YES
                 completion:NULL];

Requirements

To correctly compute the height of the presented view controller, it must either satisfy Auto Layout constraints for a height using systemLayoutSizeFitting(UIView.layoutFittingCompressedSize) or have a non-zero preferredContentSize.

Github

link
Stars: 12

Dependencies

Used By

Total: 0

Releases

1.0.0 Release Candidate 2 -

  • Fixes a regression with the PassthroughView when the dimmingViewAlpha value of SheetPresentationOptions is set to nil.

1.0.0 Release Candidate 1 -

  • Added the ability to present from any edge of the view.
  • Removed Objective-C support, simplifying the API.
  • Changed the name of the library to SheetPresentation.