• Stars
    star
    293
  • Rank 141,748 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 12 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

Swipe in view controllers from off-screen similar to Check the Weather.

RNSwipeViewController

Seemlessly integrate beautifully functional view controllers into your app that are accessible with just the swipe of a finger. Inspiration for this project came from David Smith and his gorgeous app Check The Weather.

iPad support added along with example on 11/8/12.

View the Docs

Check out the Demo Excuse the graphics glitches.

Installation

Drag the included RNSwipeViewController folder into your project. Then, include the following frameworks under Link Binary With Libraries:

  • QuartzCore.framework

That's it.

Usage

In the provided example, I have a swipe controller setup via Storyboards. However, you should be able to create your controllers with NIBs or plain code. Using the swipe controller is similar to using a UINavigationController in that RNSwipeViewController is a container of child view controllers. All interaction logic is controlled with the swipe controller. All of your app's logic should be contained in your child view controllers.

I would also recommend subclassing RNSwipeViewController like I've done in the example. However, you shouldn't have to.

Create view controllers as you deem necessary and assign them to the swipe controller's respective sides. RNSwipeViewController will handle enabling/disabling of gestures for you.

self.centerViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"centerViewController"];
self.leftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"leftViewController"];
self.rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rightViewController"];
self.bottomViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"bottomViewController"];

With minimal effort, your views are now setup.

Setup in Code

If you want to avoid Storyboards (I don't blame you), you can setup everything in code. Here is an example from the AppDelegate of a app of mine.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // PTMasterController is a subclass of RNSwipeViewController
    PTMasterController *masterController = [[PTMasterController alloc] init];
 
    PTSchemeController *scheme = [[PTSchemeController alloc] init];
    PTUtilityController *utility = [[PTUtilityController alloc] init];
    PTWritingController *writing = [[PTWritingController alloc] init];
    
    masterController.centerViewController = writing;
    masterController.rightViewController = utility;
    masterController.leftViewController = scheme;
    
    masterController.leftVisibleWidth = kGridSize + 3 * kPadding;
    masterController.rightVisibleWidth = kGridSize * 2 + 3 * kPadding;
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
 
    self.window.rootViewController = masterController;
 
    self.window.backgroundColor = [UIColor underPageBackgroundColor];
    [self.window makeKeyAndVisible];
    
    return YES;
}

Performance

Expect decent performance on the iPhone 4 or later. However on newer devices (4S+) you should expect 60fps.

Config

You can customize the width of each view controller's panel at run-time. Make sure the views in your view controllers are prepared to be smaller than your device's width/height.

@property (assign, nonatomic) CGFloat leftVisibleWidth;     // default 200
@property (assign, nonatomic) CGFloat rightVisibleWidth;    // default 200
@property (assign, nonatomic) CGFloat bottomVisibleHeight;  // default 300

Categories (optional)

You can also include the helpful UIViewController+RNSwipeViewController category to make finding and using the swipe controller easier. Just import the .h/.m files into your controller and call the swipeController property.

@implementation YourViewController

- (IBAction)toggleLeft:(id)sender {
    [self.swipeController showRight];
}

@end

Delegation, Notification, and KVO

I've included some helpers in case you need to know when and what view controllers are showing (or hiding). Take a look at the documentation for help with the delegate. Below I've listed the available NSNotificationCenter keys.

NSString * const RNSwipeViewControllerLeftWillAppear;
NSString * const RNSwipeViewControllerLeftDidAppear;
NSString * const RNSwipeViewControllerRightWillAppear;
NSString * const RNSwipeViewControllerRightDidAppear;
NSString * const RNSwipeViewControllerBottomWillAppear;
NSString * const RNSwipeViewControllerBottomDidAppear;
NSString * const RNSwipeViewControllerCenterWillAppear;
NSString * const RNSwipeViewControllerCenterDidAppear;

The only real KVO-purposed property in here is isToggled. If there is a need for more options I'll add them.

Percent Protocol

New Feature

Your left, right, and bottom view controllers can optionally conform to the RNRevealViewControllerProtocol protocol in order to receive updates on how far the view controller is presented. The percent is an integer 0 to 100. The only method this protocol uses is:

- (void)changedPercentReveal:(NSInteger)percent;

The example updates views in the left and right controller.

Status

If you're interested in what your swipe controller looks like presently, you can ask the visibleState property what is showing. The possibilities are

RNSwipeVisibleLeft
RNSwipeVisibleCenter
RNSwipeVisibleRight
RNSwipeVisibleBottom

Or, if you need to access the presented view controller directly, you can do so.

UIViewController *visibleController = self.swipeController.visibleController;

Apps

If you've used this project in a live app, please let me know! Nothing makes me happier than seeing someone else take my work and go wild with it.

Contact

License

See LICENSE

More Repositories

1

RNFrostedSidebar

A Control Center-esque control with blurred background and toggle animations.
Objective-C
2,125
star
2

RNGridMenu

A grid menu with elastic layout, depth of field, and realistic animation.
Objective-C
1,282
star
3

RNBlurModalView

Add depth to your alerts.
Objective-C
830
star
4

RNRippleTableView

A custom table view with highly detailed ripple animations.
Objective-C
390
star
5

RNThemeManager

Easily manage themes and respond to theme changes by updating views in real time.
Objective-C
322
star
6

HackerNewsReader

A small, read-only app for Hacker News.
Objective-C
261
star
7

WeatherKit

A quick and elegant solution to gathering local weather data.
Objective-C
166
star
8

UITableViewController-Containment-Demo

This is a sample project showing how to contain a UITableViewController in another VC with a Search Bar + Display Controller working as if it were all in a UITableViewController.
Objective-C
135
star
9

RNExpandingButtonBar

iOS UI widget that mimics the famous button used by the app Path.
Objective-C
126
star
10

RNTextStatistics

A category on NSString to gather advanced statistics on text.
Objective-C
124
star
11

RNBoilerplate

A bundle of my necessary frameworks, libraries, helpers, and settings for each Xcode project with configurable options.
Objective-C
106
star
12

SimpleWeather

A personal weather app I'm building in the open.
Swift
83
star
13

RNSwipeBar

Custom iOS widget to swipe a tab bar from the bottom of the screen
Objective-C
66
star
14

RNAvatarLogin

A simple way to autocomplete Gravatar icons for text fields.
Objective-C
57
star
15

Swift-CoreData

An extremely simple Core Data backed Swift app
Swift
55
star
16

PopDemos

Some demos of Facebook's Pop library made for a RayWenderlich.com tech talk.
Objective-C
53
star
17

TransitionExample

Testing UIViewControllerAnimatedTransitioning
Objective-C
42
star
18

World-Cup-Matches

Very simple app to keep an eye on World Cup 2014 matches.
Objective-C
39
star
19

Metro-Lights

A dark Xcode theme inspired by City Lights for Atom.
34
star
20

IGListKit-Binding-Guide

Starter and finished project for binding guide.
Objective-C
33
star
21

Xcode-Empty-Application

Adding the Empty Application template back to Xcode
30
star
22

UISVC-Compatibility-Demo

UISplitViewController setup that works on iOS 7 with all devices (iPhones + iPads).
Swift
30
star
23

VectorKit

A vector library and playground
Swift
29
star
24

D3Kit

An easy to use iOS library to access the Diablo 3 API.
Objective-C
28
star
25

OneNews-Swift

A work-in-progress universal iOS app for reading Hacker News, Designer News, and Product Hunt.
Objective-C
26
star
26

From-Scratch-Guides

Collection of guides & tutorials about building software from nothing.
25
star
27

WatchKit-by-Tutorials

Repository for all sample code in the upcoming WatchKit by Tutorials book from Ray Wenderlich.
Objective-C
20
star
28

IGListKit-Benchmarks

Benchmark tests for IGListKit
Swift
17
star
29

RNMDParser

Sample application experimenting with Obj-C Markdown parsing.
Objective-C
16
star
30

BottleRocket

An experimental CLI tool for generating normalized Swift models from example JSON responses.
Swift
12
star
31

New-Awesome-Blog

Showing off my awesome blog!
HTML
11
star
32

leadership

[WIP] My thoughts, principles, and resources on leadership.
11
star
33

NSString-RNSynonyms

A fast and lightweight solution to finding synonyms for words, built as a category on NSString.
Objective-C
11
star
34

RNTableView

A recreation of UITableView with only the bear essentials. Use this to start a highly customized UITableView.
Objective-C
11
star
35

WatchKit-Threading

A really simple demo app showing that threading in WatchKit works.
Objective-C
10
star
36

Arduino-HomeKit

HTML
9
star
37

RWDevCon-View-Controller-Transitions

Objective-C++
8
star
38

RNCardStreamController

A vertical section and cell navigation control inspired by Facebook Paper.
Objective-C
8
star
39

Armory-for-Diablo-3

Source code for my Armory app that is awaiting Apple approval.
Objective-C
7
star
40

WeatherExample

Building a Weather app example using ReactiveCocoa for raywenderlich.com
Objective-C
6
star
41

status-checklists

Action to that updates Issue state with checklists
TypeScript
5
star
42

create-child-issues

Action to generate child issues with labels.
JavaScript
5
star
43

Crateless

https://itunes.apple.com/us/app/crateless/id563997439?ls=1&mt=8
Objective-C
5
star
44

.github-template

4
star
45

Playground

Link: https://github.com mention: @rnystrom
3
star
46

RNNumberedTextView

Easily add customizable line numbers to UITextView.
Objective-C
2
star
47

issue-actions

WIP actions to sync parent and child issues.
JavaScript
2
star
48

M3Demo

Objective-C
2
star
49

HackerNews-iOS

Objective-C
1
star
50

Blog

Nothing special.
CSS
1
star
51

dotfiles

1
star
52

Read-Write-Protection-Perf

Teeny tiny profiling of different ways to protect mutations in your objects.
Objective-C
1
star
53

SunlightTest

Sample app to test background and text colors in sunlight
Objective-C
1
star