README.md

About

iOS let's you modally present any view controller, but if you want the presented view controller to not cover the whole screen or modify anything about its presentation or transition you have to use the Custom View Controller Presentation API's.

This can be cumbersome, specially if you do it multiple times in your app. Presentr simplifies all of this. You just have to configure your Presentr object depending on how you want you view controller to be presented, and the framework handles everything for you.

These are just examples of an Alert UI presented in multiple ways. But, with Presentr you can present any custom View Controller you create in any of the Presentation types, or create your own custom one!

What's New

1.9

Support for Xcode 10 / iOS 12 / Swift 4.2

Last version before big 2.0 update

1.3.1

New FlipHorizontal transition type (thanks to @falkobuttler)

New CoverFromCorner transition type (thanks to @freakdragon)

New customOrientation ModalSize (thanks to @freakdragon)

KeyboardTranslation now works for all Presentation Type's (thanks to @oxozle)

Other bug fixes & improvements

1.3

Swift 4 / Xcode 9 / iOS 11 Support

Bug fixes

1.2.0

You can add custom BackgroundView. (thanks to @clebta)

Add custom text color for AlertViewController

New PresentationType called .dynamic that allows dynamic sizing of ViewController using AutoLayout to calculate size.

You can set the context so the presentation is done properly on a child view controller and not the whole screen.

Installation

Manually

Download and drop /Presentr folder in your project.

You're done!

Getting started

Create a Presentr object

It is important to hold on to the Presentr object as a property on the presenting/current View Controller since internally it will be used as a delegate for the custom presentation, so you must hold a strong reference to it.

You can change the background color & opacity for the background view that will be displayed below the presented view controller. You can also set a customBackgroundView that will be displayed on top of the built-in background view.

You can choose to disable dismissOnTap that dismisses the presented view controller on tapping the background. Default is true. Or you can disable the animation for the dismissOnTap and dismissOnSwipe.

presenter.dismissOnTap=false
presenter.dismissAnimated=false

You can activate dismissOnSwipe so that swiping inside the presented view controller dismisses it. Default is false because if your view controller uses any kind of scroll view this is not recommended as it will mess with the scrolling.

You can also se the direction, for example in case your ViewController is an Alert at the top, you would want to dismiss it by swiping up.

presenter.dismissOnSwipe=true
presenter.dismissOnSwipeDirection= .top

If you have text fields inside your modal and the presentationType property is set to popup, you can use a KeyboardTranslationType to tell Presentr how to handle your modal when the keyboard shows up.

If you are doing a presentation inside a SplitViewController or any other type of container/child ViewController situation you can use these properties to handle it properly.

Set the viewControllerForContext to the ViewController you want Presentr to use for framing the presentation context. shouldIgnoreTapOutsideContext is set to false by default. This handles what happens when they click outside the context (on the other ViewController).

Be sure to set the viewControllerForContext property before presenting, not on initialization, this makes sure that Auto Layout has finished it's work and the frame for the ViewController is correct.