MagicPresent is a simple customizable wrapper for the Custom View Controller Presentation API introduced in iOS 8.
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. MagicPresent simplifies all of this. You just have to configure your MagicPresent object depending on how you want you view controller to be presented, and the framework handles everything for you.
- Fork project
- Checkout master branch
- Create Feature branch off of the master branch
- Create awesome feature/enhancement/bug-fix
- Optionally create Issue to discuss feature
- Submit pull request from your Feature branch to MagicPresent's master branch
use_frameworks!
pod 'MagicPresent'
Add MagicPresent to you Cartfile
github "khuong291/MagicPresent"
Install using
carthage update --platform ios
- Download and drop
/MagicPresent
folder in your project. - You're done!
Your MagicPresent can be as simple as this:
class ViewController: UIViewController {
private var presentationVC: MagicPresent?
}
Instantiate the View Controller you want to present and use MagicPresent object to do the custom presentation.
let vc = ViewController2()
presentationVC = MagicPresent(presentedViewController: vc, presenting: self)
presentationVC?.cornerRadius = 6
presentationVC?.position = .center
present(vc, animated: true, completion: nil)
In your View Controller you want to present, set preferredContentSize with the size you want
preferredContentSize = CGSize(width: 350 , height: 350)
public enum PresentationPosition {
case bottom
case center
case top
}
open var animationDuration: Double = 0.2
open var position: PresentationPosition = .center
open var shadowEnabled = true
open var cornerRadius: CGFloat = 0
open var dismissEnabled = true
open var shadowAlpha: CGFloat = 0.5
open var shadowOpacity: Float = 0.5
open var shadowRadius: CGFloat = 5
open var shadowOffsetWidth = 0
open var shadowOffsetHeight = -3
- iOS 9.0+
- Xcode 8.0+
- Swift 3.0+
MagicPresent is released under the MIT license.
See LICENSE for details.