We have all been in situations where designers think an app should behave as a website does. Especially, when you see designs with a bunch of modals. BGPartialModals to the rescue! BGPartialModals makes presenting web-like modals easy for iOS.
Download the files and run the demo app and check out the source code. Check out the docs.
- iOS 4.3+
- QuartzCore.framework
- ARC
- Link against the QuartzCore.framework
- Add the BGPartialModal source folder to your project. Make sure you have Copy items into destination group's folder checked. Also, check your target in the Add to targets view.
- Create a new Objective-C class and make it a subclass of BGPartialModalViewController. Make sure the With XIB for user interface is checked.
- In the XIB file do the following:
- Drag and drop a new UIView into your main view.
- Reference it to the modalView outlet.
- Customize your modal view however you like.
- Do the following in the view controller where you will present the modal:
- Open the view controller's header file and add:
#import "BGPartialModalFadeTransition.h"
(replace with a transition of your choice).- Don't forget to import your modal view controller.
- Open the view controller's main file and add something similar to the following lines of code in your action method:
// initialize modal view controller MyModalViewController *myModalController = [[MyModalViewController alloc] initWithNibName:@"MyModalViewController" bundle:nil]; myModalController.enableOverlayClose = YES; // present modal [self presentViewController:myModalController overlayColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:0.75f] // overlay color with alpha animationType:[BGPartialModalFadeTransition class] // animation type completion:^{ // some completion stuff here }];
- Create an action to launch your modal, compile and run!
- Open the view controller's header file and add:
- BGPartialModalTransition: This is the father of all transitions. Feel free to subclass it to create your own awesome transitions.
- BGPartialModalFadeTransition: A simple fade transition.
More transitions are needed! Feel free to contribute or suggest any code.
- Add more transitions
- Add nice UI, and cool demo
- Create an iPad demo
- Write better documentaion
- Create visual tutorial, maybe a video