VHSlideoutController is a subclass of UIViewController that lets you set a top, left, and right view controller. You can then swipe to reveal the layers.
To run the example project, clone the repo, and run
pod install from the Example directory first.
VHSlideoutController is available through CocoaPods. To install it, simply add the following line to your Podfile:
To use VHSlideoutController you first create a new class and make it a subclass of VHSlideoutController. Then in your viewDidLoad create instances of the three view controllers you would like to designate as the left, right, and top. These view controllers will most likely have classes of their own so be sure to import the appropriate headers. The example below shows how to instantiate and embed the view controllers from the storyboard:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *left = [storyboard instantiateViewControllerWithIdentifier:@"LeftViewController"]; UIViewController *right = [storyboard instantiateViewControllerWithIdentifier:@"RightViewController"]; UIViewController *top = [storyboard instantiateViewControllerWithIdentifier:@"TopViewController"]; [self embedLeftViewController:left]; [self embedRightViewController:right]; [self embedTopViewController:top];
Again, the above is using the storyboard, but you can just as easily instantiate from a nib and then call the embed methods.
You may want to perform certain actions upon the animations completion. Because there are three view controllers to communicate with (left, right, and top), you can simply tell your subclass of VHSlideoutController to post NSNotifications. To do this you just set the following in the viewDidLoad of your VHSlideoutController subclass:
// Send Notification when animation to the left is complete self.shouldPostMovedLeftNotification = YES; // Send Notification when animation to the right is complete self.shouldPostMovedRightNotification = YES; // Send Notification when animation returning to the center is complete self.shouldPostReturnedToCenterNotification = YES;
But, be sure to add the recieving classes as observers to the Notification Center. The NSStrings below are the names of the three possible notifications:
//These are the three notification names you can choose from for the name parameter below: @"VHMovedLeftNotification" //LEFT NOTIFICATION @"VHMovedRightNotification" //RIGHT NOTIFICATION @"VHReturnedToCenterNotification" //RETURNED TO CENTER
Here's how you would add the observer:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(_SELECTOR_NAME_) name:(_NOTIFICATION STRING_) object:nil];
When no longer needed, remember to remove the observer.
[[NSNotificationCenter defaultCenter]removeObserver:self name:(_NOTIFICATION_STRING_) object:nil];
VHSlideoutController is available under the MIT license. See the LICENSE file for more info.