TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Feb 2018 |
Maintained by Gaspard Viot, Sebg82.
MaryPopin is a category on UIViewController
to present modal like controller with more flexibility.
- Wait, what? There are tons of similar projects on the web to do that!
Well, your are right, but here are some strengths of this project :
UIWindow
manipulation, MaryPopin uses UIViewControllers
containment, so rotation is properly handled,Yes, you can say it, it is Supercalifragilisticexpialidocious!
- Okay. But why MaryPopin? Popin, popup, modal may look similar, but in reality, there are some slight differences. Here, the controller view is presented inside its parent controller that is why we name it a popin controller. And as it is implemented as a category, it is as nice and magic as the famous nanny.
v1.4.2
v1.4.1
v1.4
v 1.3.1
v 1.3
v 1.2
v 1.1.1
v 1.1
v 1.0
Just add the following line in your podfile
pod 'MaryPopin'
Drag and drop the category files in your project and you are done.
The full documentation is available on CocoaDocs.
First, import UIViewController+MaryPopin.h
header.
In your current view controller, you can create a view controller and present it as a popin.
//Create the popin view controller
UIViewController *popin = [[UIViewController alloc] initWithNibName:@"NibName" bundle:@"Bundle"];
//Customize transition if needed
[popin setPopinTransitionStyle:BKTPopinTransitionStyleSlide];
//Add options
[popin setPopinOptions:BKTPopinDisableAutoDismiss];
//Customize transition direction if needed
[popin setPopinTransitionDirection:BKTPopinTransitionDirectionTop];
//Present popin on the desired controller
//Note that if you are using a UINavigationController, the navigation bar will be active if you present
// the popin on the visible controller instead of presenting it on the navigation controller
[self presentPopinController:popin animated:YES completion:^{
NSLog(@"Popin presented !");
}];
Respectively, to dismiss the popin from your current view controller
[self dismissCurrentPopinControllerAnimated:YES completion:^{
NSLog(@"Popin dismissed !");
}];
By default, popin is centered in the parent controller view. But you can provide a CGRect
in which the popin should be centered. Note that the CGRect
must be included in the parent controller view bounds, otherwise it may lead to unexpected behaviors.
BKTPopinControllerViewController *popin = [[BKTPopinControllerViewController alloc] init];
[popin setPopinTransitionStyle:BKTPopinTransitionStyleCrossDissolve];
[popin setPopinTransitionDirection:BKTPopinTransitionDirectionTop];
CGRect presentationRect = CGRectOffset(CGRectInset(self.view.bounds, 0.0, 100.0), 0.0, 200.0);
[self.navigationController presentPopinController:popin fromRect:presentationRect animated:YES completion:^{
NSLog(@"Popin presented !");
}];
The sample project show how to present and dismiss a popin with different transition styles.
If you are using CocoaPods in version 0.29 or better, you can quickly run the demo project with the following command line :
pod try MaryPopin
MaryPopin requires Xcode 5 as it uses (optionally) UIKit Dynamics and motion effects. You can use iOS 5 as a target deployment version. Note that some transition styles are not supported under iOS 7 and will be replaced by the default transition style.
MaryPopin uses ARC.
If you are using MaryPopin in a non-arc project, you will need to set a -fobjc-arc
compiler flag on every MaryPopin source files.
To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Then select MaryPopin source files, press Enter, insert -fobjc-arc and then "Done" to enable ARC for MaryPopin.
Contributions for bug fixing or improvements are welcomed. Feel free to submit a pull request.
MaryPopin is available under the MIT license. See the LICENSE file for more info.