JVTransitionAnimator 是一个简单的辅助框架,可以让你以非常酷的方式显示 View Controllers,使用过渡动画。非常容易使用和自定义。
预览
• 自定义动画
• 预定义动画
使用方法
要运行示例项目,请克隆仓库,并首先从示例目录运行 pod install
。
- 现在,只需创建一个 JVTransitionAnimator 属性。
- (JVTransitionAnimator *)transitionAnimator
{
if(!_transitionAnimator)
{
_transitionAnimator = [[JVTransitionAnimator alloc] init];
}
return _transitionAnimator;
}
- 要启用交互式过渡,您可以这样做,例如,在 UIViewController 的 viewDidAppear 中。同时,我们需要设置我们的过渡代理。
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// we need to tell our transition animator the current view controller & the new controller to be pushed
self.transitionAnimator.fromViewController = self;
self.transitionAnimator.toViewController = self.secondController;
// enabling interactive transitions
self.transitionAnimator.enabledInteractiveTransitions = YES;
// also don't forget to tell the new UIViewController to be presented that we will be using our animator & choose the animation
self.transitionAnimator.slideInOutAnimation = YES;
self.secondController.transitioningDelegate = self.transitionAnimator;
}
- 然后,我们可以进一步设置和自定义我们的过渡动画。
// here is the trick if you want longer animations or set a delay or event not bouncing (known as dampling) at all
self.transitionAnimator.duration = 1.0f;
self.transitionAnimator.delay = 0.0f;
self.transitionAnimator.damping = 0.5f;
self.transitionAnimator.velocity = 0.9f;
- 最后,要触发过渡,我们只需要进行 simple presentViewController 函数调用。
// whenever you want to present the new view controller animated
[self presentViewController:self.secondController animated:YES completion:nil];
要求
开发和测试使用 iOS8+。
安装
JVTransitionAnimtor 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
pod "JVTransitionAnimator"
作者 & 支持
如果您发现任何错误或改进空间,请与我联系。Jorge Valbuena (@JV17), [email protected]. 顺便说一句!欢迎您帮助支持此 pod 或对其做出改进。
许可协议
JVTouchEventsWindow 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。