博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[翻译] CBStoreHouseTransition
阅读量:5292 次
发布时间:2019-06-14

本文共 3435 字,大约阅读时间需要 11 分钟。

CBStoreHouseTransition

What is it?

A custom transition inspired by  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  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
)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
)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id
)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;

转载于:https://www.cnblogs.com/YouXianMing/p/4040238.html

你可能感兴趣的文章
程序员的“机械同感”
查看>>
在16aspx.com上下了一个简单商品房销售系统源码,怎么修改它的默认登录名和密码...
查看>>
c++回调函数
查看>>
linux下Rtree的安装
查看>>
【Java】 剑指offer(53-2) 0到n-1中缺失的数字
查看>>
Delphi中ListView类的用法
查看>>
bzoj3110: [Zjoi2013]K大数查询 【树套树,标记永久化】
查看>>
[原创]Java 的传值小例子
查看>>
博客第一弹—聊聊HTML的那些事
查看>>
Mysql安装方法及安装问题解决
查看>>
Java动态代理的两种实现方式:
查看>>
PHP trait
查看>>
python 多线程并发threading & 任务队列Queue
查看>>
1_fbauto
查看>>
IO体系、集合体系、多线程、jdbc
查看>>
关于时间:UTC/GMT/xST/ xDT
查看>>
[51Nod1089] 最长回文子串 V2(Manacher算法)
查看>>
Asp.Net生命周期系列六
查看>>
php引用 =& 详解
查看>>
Codeforces 914D Bash and a Tough Math Puzzle (ZKW线段树)
查看>>