Giter Club home page Giter Club logo

cwstackcontroller's Introduction

CWStackController

CWStackController is a UINavigationController like custom container view controller which provides fullscreen pan gesture support to POP and PUSH , inspired by Netease News and used in my recent app cnBeta Reader.

demo gif

Usage

CWStackController's APIs are pretty much like UINavigationController's which make it very easy to use:

// Init
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController;

// Push
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;

// Pop
- (UIViewController *)popViewControllerAnimated:(BOOL)animated;
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated;

// Accessing
@property (nonatomic) NSArray *viewControllers;
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated;
@property (nonatomic, readonly) UIViewController *topViewController;

Enable to push new controller through pan gesture:

Assume you have a view controller A is in the CWStackController stack, you want push a new view controller B into stack through pan gesture, all you need is let A confirms to CWStackProtocol and implements - (UIViewController *)nextViewController:

// A.m
- (UIViewController *)nextViewController
{
	return B;
}

You can customize the threshold to trigger a push or pop through pan gesture, the duration for animations and the shadow.

Work with scroll view:

CWStackController works well with scroll view now, if you want have scroll view in the child view controller and you want to PUSH or POP by drag it, you need to set scroll view to CWStackController instance using it's API:

- (void)setContentScrollView:(UIScrollView *)scrollView;

See Demo project for more details.

Installation

There are two options:

  1. CWStackController is available as CWStackController in CocoaPods.
  2. Drag CWStackController folder from demo project into your Xcode project.

Requirement

  • iOS 5.0 or higher
  • ARC

License

CWStackController is available under the MIT license. See the LICENSE file for more info.

cwstackcontroller's People

Contributors

guojiubo avatar

Watchers

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