zoukankan      html  css  js  c++  java
  • [翻译] CBStoreHouseTransition

    CBStoreHouseTransition

    What is it?

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

    一个自定义转场效果,灵感来自于Storehouse的app,支持pop的手势.

    Features

    • One class file includes both pop and push transition and pop gesture. 一个类文件包含了pop与push动画效果以及pop手势
    • Fully customizable transition animation. 完全定制的转场动画
    • Works for following iOS custom transition types:  支持以下的iOS定制动画类型
      • UINavigationControllerpush and pop  UINavigationController的push与pop操作
      • UIViewController presentations and dismissals  UIViewController 的dismissal与presentations操作

    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!

    你只需要将CBStoreHouseTransition(.h .m)引入到你的项目当中,他们已经包含了动画器以及交互的实现.

    而且很快就会支持CocoaPods!

    How to use it

    For animator object you need to set proper AnimationType to matchUINavigationControllerOperation object.

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

    对于动画器对象,你需要设置AnimationType到matchUINavigationControllerOperation对象当中.

    对于交互式转场动画,你需要获取到将当前控制器的view

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

    屏幕边缘的手势被添加到了控制器的root的view当中,用来处理以及驱动动态转场交互效果.

    然后,返回合适的动画器对象或者在代理方法中返回交互对象,以下的例子就是用CBStoreHouseTransition来进行UINavigationController转场动画的.

    - (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:

    一旦我们不想用动态交互来push或者想用返回按钮那种简单的方式,你需要设置self.interactive为nil.

    你可以定制如下的一些参数来改变动画的效果:

    @property (nonatomic) CGFloat duration;
    @property (nonatomic) CGFloat rotateAngle;
    @property (nonatomic) CGFloat relativeDelayLeftView;
    @property (nonatomic) CGFloat relativeDelayRightView;
    @property (nonatomic) CGFloat percentageAdjustFactor;
  • 相关阅读:
    springboot(eureka子项目)+idea+jsp 404问题
    什么是区块链以及他的6个特征?
    elasticsearch启动时提示内存不足错误的解决方法
    ElasticSearch 安装root用户启动失败问题解决
    防抖节流(立即执行和延时执行)
    将数字转为千分制格式(最简单)
    微信H5跳转任意小程序
    原生html+css设置项目主题色(超简单)
    H5获取手机型号
    css属性——env()和constant()设置安全区域
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4040238.html
Copyright © 2011-2022 走看看