All Projects → joemasilotti → CustomHeightPresentationController

joemasilotti / CustomHeightPresentationController

Licence: MIT License
A presentation wrapper to show a controller that doesn't fill the full screen.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

CustomHeightPresentationController

A tiny library (one UIViewController) that makes presenting modal screens much easier. It mimics the presentation animation and feel of UIActionSheet but leaves all design to the developer. A custom controller is animated up from the bottom of the screen and the view "underneath" is grayed out. Tapping anywhere on the presenting view will dismiss the presented controller.

Example

Screenshot

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

CustomHeightPresentationController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'CustomHeightPresentationController'

Create a UIViewController that conforms to CustomHeightPresentable and add the following to init():

modalPresentationStyle = .custom
transitioningDelegate = self

Then in that controller's extension of UIViewControllerTransitioningDelegate add the following:

func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
    return CustomHeightPresentationController(presentedViewController: presented, presenting: presenting)
}

A full implementation exists in the example project.

Author

Joe Masilotti, [email protected]

License

CustomHeightPresentationController is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].