MSSlideNavigationController icon indicating copy to clipboard operation
MSSlideNavigationController copied to clipboard

Facebook like UINavigationController to slide back to previous view controller.

MSSlideNavigationController

Facebook like UINavigationController to slide back to previous view controller.

animation

Get it ready

The best way to add it inside your project is with CocoaPods: simply add

pod 'MSSlideNavigationController'

inside your Podfile.

Origins and how it works

MSSlideNavigationController is a subclass (and a kind of hack!) of UINavigationController. It was originally created by the hacker @chpwn for Facebook:

facebook

And the response was quite good:

I don't know about Grant Paul's implementation, but mine works creating a screenshot of the previous view controller as soon as the user starts scrolling, animating bar button items based on user's scroll.

How to use

Whenever you want to add this feature to your navigation controller's hierarchy, you have to do a couple of things.

First of all, use MSSlideNavigationController instead of UINavigationController (course)

If you want the fade animation for bar button items (and I am sure you do want it), the only way is to create them with a custom view, adding the actual view as a subview of the "main" custom view. An example is probably what you need:

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 33)];
[button setTitle:@"A" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(yourAction) forControlEvents:UIControlEventTouchUpInside];
UIView *view = [[UIView alloc] initWithFrame:button.frame];
[view addSubview:button];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];

And remebember to keep bar button items' sizes constant.

Credits

Freely inspired by Facebook

Contact

Marco Sero

License

MSSlideNavigationController is available under the MIT license. See the LICENSE file for more info.