测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
Released上次发布 | 2015年1月 |
由 Alek Åström 维护。
AWPercentDrivenInteractiveTransition
是用于自定义容器视图控制器的 UIPercentDrivenInteractiveTransition
的替代方案。
为什么你需要它?因为苹果自家的 UIPercentDrivenInteractiveTransition
在你的自定义 UIViewControllerContextTransitioning
对象上调用未经文档记录的方法。
请注意,此类可以用作 UIKits 标准容器视图控制器,例如 UINavigationController
、UITabBarController
,并且也可以用于显示模态视图控制器。
0.2.0 - 添加了对更改 completionSpeed
的支持
completionSpeed
从 1.0 无法更改completionCurve
无法从 UIViewAnimationCurveLinear
更改UIViewControllerTransitionCoordinator
(用于动画过渡期间的其他视图)或者,您可以直接将 AWPercentDrivenInteractiveTransition.h
和 AWPercentDrivenInteractiveTransition.m
源文件添加到您的项目中。
AWPercentDrivenInteractiveTransition.h
和 AWPercentDrivenInteractiveTransition.m
拖放到项目中(使用 "Product Navigator view")。如果您在项目外部提取了代码归档,请确保在询问时选择复制项目。#import "AWPercentDrivenInteractiveTransition.m"
,在任何需要的地方包含 AWPercentDrivenInteractiveTransition。如果您不想始终编译我的代码,lib
文件夹中有一个 XCode 项目可以生成您可以包含在项目中的静态 libAWPercentDrivenInteractiveTransition.a
库文件。只需记住在源代码中包含原始的 LICENCE
文件即可。
如图常规 UIPercentDrivenInteractiveTransition
一样使用。要么是通过让您的自定义交互控制器子类化 AWPercentDrivenInteractiveTransition
,要么是有一个实例并手动调用 updateInteractiveTransition:
、cancelInteractiveTransition
和 finishInteractiveTransition
方法。
唯一的区别是,在开始交互式过渡之前,您需要设置 animator 属性为 UIViewControllerAnimatedTransitioning
对象。
这是标准 UIPercentDrivenInteractiveTransition
通过调用您 UIViewControllerContextTransitioning
对象的私有方法所执行的操作。
还有一个便利的初始化方法名为 initWithAnimator:
,它直接设置 animator 属性。
如果您想看到这个插入式替换类的实际演示,请查看我在Interactive Custom Container View Controller Transitions上的博客文章。
此代码分发符合 MIT 许可证的条款和条件。