Giter VIP home page Giter VIP logo

cbstorehousetransition's Introduction

CBStoreHouseTransition

What is it?

A custom transition inspired by Storehouse iOS app, also support pop gesture.

![screenshot] (https://s3.amazonaws.com/suyu.test/CBStoreHouseTransition.gif)

Video

CBStoreHouseTransition

Features

  • One class file includes both pop and push transition and pop gesture.
  • Fully customizable transition animation.
  • Works for following iOS custom transition types:
    • UINavigationControllerpush and pop
    • UIViewControllerpresentations and dismissals

Which files are needed?

You only need to include CBStoreHouseTransition (.h .m) in your project, it contains both animator and interactive class.

CocoaPods support is coming very soon!

How to use it

For animator object you need to set proper AnimationType to match UINavigationControllerOperation object.

For interactive transition you need to attach current view controller using:

- (void)attachToViewController:(UIViewController *)viewController;

A edge pan gesture will be added on the view controller's root view to handle the pop gesture and drive the interactive transition.

Then just return the proper animatior or interactive object in related delegate method, following is a example using CBStoreHouseTransition for UINavigationController.

For more information about iOS custom transition, please refer to WWDC 2013 Custom Transitions Using View Controllers video.

- (void)viewDidLoad
{
    ...
    self.animator = [[CBStoreHouseTransitionAnimator alloc] init];
    ...
}

- (void)viewDidAppear:(BOOL)animated
{
    ...
    self.navigationController.delegate = self;
    self.interactiveTransition = [[CBStoreHouseTransitionInteractiveTransition alloc] init];
    [self.interactiveTransition attachToViewController:self];
    ...
}

-(id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                 animationControllerForOperation:(UINavigationControllerOperation)operation
                                              fromViewController:(UIViewController *)fromVC
                                                toViewController:(UIViewController *)toVC
{
    switch (operation) {
        case UINavigationControllerOperationPush:
            //we don't need interactive transition for push
            self.interactiveTransition = nil;
            self.animator.type = AnimationTypePush;
            return self.animator;
        case UINavigationControllerOperationPop:
            self.animator.type = AnimationTypePop;
            return self.animator;
        default:
            return nil;
    }
}

- (id<UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
                         interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController
{
    return self.interactiveTransition;
}

Since we don't need interactive for push transition or when user specificity taps back button, you need to set self.interactive to nil.

You can customize following properties to change the animation behavior:

@property (nonatomic) CGFloat duration;
@property (nonatomic) CGFloat rotateAngle;
@property (nonatomic) CGFloat relativeDelayLeftView;
@property (nonatomic) CGFloat relativeDelayRightView;
@property (nonatomic) CGFloat percentageAdjustFactor;

cbstorehousetransition's People

Contributors

coolbeet avatar

Watchers

Yuan,Xin 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.