https://github.com/khuong291/magicpresent
🐉 A lightweight Swift wrapper for custom ViewController presentations on iOS
https://github.com/khuong291/magicpresent
animate custom present show swift
Last synced: 11 months ago
JSON representation
🐉 A lightweight Swift wrapper for custom ViewController presentations on iOS
- Host: GitHub
- URL: https://github.com/khuong291/magicpresent
- Owner: khuong291
- License: mit
- Created: 2017-10-26T09:27:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-07T08:57:14.000Z (over 8 years ago)
- Last Synced: 2025-07-20T18:08:41.764Z (11 months ago)
- Topics: animate, custom, present, show, swift
- Language: Swift
- Homepage:
- Size: 234 KB
- Stars: 9
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](http://cocoapods.org/pods/MagicPresent)
[](https://github.com/Carthage/Carthage)
[](https://developer.apple.com/swift/)
[](http://cocoapods.org/pods/MagicPresent)
[](http://cocoapods.org/pods/MagicPresent)
*MagicPresent is a simple customizable wrapper for the Custom View Controller Presentation API introduced in iOS 8.*
## 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. **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.



## Contributing
1. Fork project
2. Checkout **master** branch
3. Create **Feature** branch off of the **master** branch
4. Create awesome feature/enhancement/bug-fix
5. Optionally create *Issue* to discuss feature
6. Submit pull request from your **Feature** branch to MagicPresent's **master** branch
## Installation
### [Cocoapods](http://cocoapods.org)
```ruby
use_frameworks!
pod 'MagicPresent'
```
### [Carthage](https://github.com/Carthage/Carthage)
Add MagicPresent to you `Cartfile`
```sh
github "khuong291/MagicPresent"
```
Install using
```sh
carthage update --platform ios
```
### Manually
1. Download and drop ```/MagicPresent``` folder in your project.
2. You're done!
## Getting started
### Create a MagicPresent object
Your **MagicPresent** can be as simple as this:
```swift
class ViewController: UIViewController {
private var presentationVC: MagicPresent?
}
```
### Present the view controller.
Instantiate the View Controller you want to present and use **MagicPresent** object to do the custom presentation.
```swift
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
```swift
preferredContentSize = CGSize(width: 350 , height: 350)
```
## Main Types
### Presentation Position
```swift
public enum PresentationPosition {
case bottom
case center
case top
}
```
## Properties
#### Properties are optional, as they all have Default values.
```swift
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
```
## Requirements
* iOS 9.0+
* Xcode 8.0+
* Swift 3.0+
## Author
[Khuong Pham](http://kasler.net)
## License
MagicPresent is released under the MIT license.
See LICENSE for details.