Facebook like UINavigationController to slide back to previous view controller.
Objective-C
Latest commit e16e526 May 27, 2013 @MarcoSero +
Permalink
Failed to load latest commit information.
.idea first commit May 27, 2013
MSSlideControllerDemo.xcodeproj + May 27, 2013
MSSlideControllerDemo + May 27, 2013
MSSlideNavigationController added readme and project refactor May 27, 2013
LICENSE added readme and project refactor May 27, 2013
README.md + May 27, 2013

README.md

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

@aaronash you should try the swipe back gesture I did for the latest Facebook update

— Grant Paul (chpwn) (@chpwn) 13 maggio 2013

And the response was quite good:

Dynamic swipe back behaviour in UINavigationControllers (like Flurry and the new Facebook app update) need to be a thing. They're awesome.

— Adam Bell (@b3ll) 14 maggio 2013

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.