Skip to content

Sebacho-Barajas/Snapchat-Swipe-View

 
 

Repository files navigation

Snapchat-Swipe-View

Hide more ViewControllers in ALL the directions! Snapchat-Swipe-View mimics the classic 2015 Snapchat top, down, left, and right swiping that lets you go to a different view controller in every direction. There are versions of this that let you scroll to the left and right, but not up and down as well, which required some additional hacking.

Demo

How to use:

  1. Add SnapContainerViewController.swift and VerticalScrollViewController.swift to your project

  2. Make sure your project supports swift

  3. If you are using Storyboards, ensure you have an arbitrary initial view controller set in your storyboard. If you use the code in step 4, the middle view controller will always be shown first, so this is needless but you will get an error if you don't do it.

  4. In your App Delegate:

Swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
    // ...
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let left = storyboard.instantiateViewControllerWithIdentifier("left")
    let middle = storyboard.instantiateViewControllerWithIdentifier("middle")
    let right = storyboard.instantiateViewControllerWithIdentifier("right")
    let top = storyboard.instantiateViewControllerWithIdentifier("top")
    let snapContainer = SnapContainerViewController.containerViewWith(left, middleVC: middle, rightVC: right, topVC: top)
    self.window?.rootViewController = snapContainer
    self.window?.makeKeyAndVisible()
    // ...
}

Objective-C

#import "ProductModuleName-Swift.h"
// ....


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ...
    UIStoryboard *storyboard;  
    storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *left = [storyboard instantiateViewControllerWithIdentifier:@"left"];
    UIViewController *middle = [storyboard instantiateViewControllerWithIdentifier:@"middle"];
    UIViewController *right = [storyboard instantiateViewControllerWithIdentifier:@"right"];
    UIViewController *top = [storyboard instantiateViewControllerWithIdentifier:@"top"];
    
    

    SnapContainerViewController *snapContainer = [SnapContainerViewController containerViewWith:left middleVC:middle rightVC:right topVC:top];
    
     self.window.rootViewController = snapContainer;
    [self.window makeKeyAndVisible ];
    
// ...

}

NOTE: If any of your view controllers depend on scroll gestures (e.g. UITableViewController) be aware that only the left and right view controllers can recieve vertical scroll gestures. Horizontal scroll gestures are not supported anywhere, and vertical ones arent supporeted on the middle view controllers because it wouldnt make sense (you will notice snapchat doesnt use them either).

About

Handy four way snapchat style scrolling UI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%