[翻译] CBStoreHouseTransition

一个自定义转场效果,灵感来源于Storehouse iOS应用,支持pop手势。该类文件同时包含pop与push动画及pop手势功能,适用于UINavigationController的push与pop操作。

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:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值