• Stars
    star
    160
  • Rank 234,703 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

@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.

More Repositories

1

MSMatrixController

A component to organize your view controllers in a gesture-based 2D matrix.
Objective-C
133
star
2

EditorConfig-Xcode

Plugin to add EditorConfig support to Xcode
Objective-C
117
star
3

HackerNews

An open source, beautifully designed Hacker News client for iPhone
HTML
111
star
4

Nimble

Core Data and iCloud made nimble and fast
Objective-C
98
star
5

MSNavigationSwipeController

Subclass of UINavigationController to add 'swipe right to go back' gesture recognizer like most apps (Facebook, Tweetbot) already do.
Objective-C
72
star
6

MSMapClustering

A subclass of MKMapView to cluster annotations
Objective-C
52
star
7

Swiftener

Collection of extensions, operators and utilities to add syntactic sugar to Swift
Swift
20
star
8

Norvigs-Spelling-Corrector

A Haskell implementation of Peter Norvig's spelling corrector
Haskell
15
star
9

PolyglotApp

A Polyglot iOS Application
Objective-C
11
star
10

CKComponentFadeTransition

A ComponentKit extension to add fade transitions.
Objective-C++
8
star
11

dotfiles

My dotfiles
Vim Script
7
star
12

Algorithms

Small collection of simple algorithms written in Swift
Swift
6
star
13

SpringBoard-iOS-5.0

iOS 5.0 headers Springboard.app
Objective-C
5
star
14

MSBlockSegues

Block-based Storyboard Segues
Objective-C
4
star
15

userl

A CLI to get the most used languages of a GitHub user
Ruby
3
star
16

lifeofadev.eu

Ruby on Rails CMS that I use to run my blog
JavaScript
2
star
17

StatusBoard-BitBucket

Ruby
2
star
18

toSync

A simple Java program to synchronize folders
Java
2
star
19

SnoozeOrStop

iOS Tweak. Adds the button to stop alarm in Lockscreen or stops it with lock button
Objective-C
2
star
20

gruber

A not very functional (yet) Markdown parser written in Haskell
Haskell
1
star
21

Mail-my-IP

A program that notifies the change of the public IP via email
Java
1
star
22

msChat

A simple Java-based chat for educational purposes
Java
1
star