Giter Site home page Giter Site logo

xuantungsp / msslidenavigationcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marcosero/msslidenavigationcontroller

0.0 2.0 0.0 585 KB

Facebook like UINavigationController to slide back to previous view controller.

License: MIT License

msslidenavigationcontroller's Introduction

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
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

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
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

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.

msslidenavigationcontroller's People

Contributors

marcosero avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.