场景
项目中碰见一个场景,VC
没有UINavigationController
,可是须要Push
和Pop
的动画效果。 一开始使用了MZFormSheetPresentationViewController
来实现Push
效果,可是却没有Pop
的边缘返回手势。本着求Github
不如求己的原则,手撸了一个库出来,WHPopAnimation
。git
Push/Pop转场效果及实现
Push
转场效果github
view.frame
从右屏外平移到屏幕正中VC
透明度从1.0
变成0.5
VC
向左平移1100.3s
Pop
转场效果bash
view.frame
从屏幕正中平移到右屏外VC
透明度从0.5
变成1.0
VC
向右平移1100.4s
VC
的self.view
须要添加UIScreenEdgePanGestureRecognizer
边缘手势,平移超过屏幕中线则dismiss(Pop)
,反之回弹回去。实现:<UIViewControllerAnimatedTransitioning>协议
和UIPercentDrivenInteractiveTransition
手势过渡管理对象动画
WHPopAnimation 接入说明
无需管理<UIViewControllerAnimatedTransitioning>协议
和UIPercentDrivenInteractiveTransition
手势过渡管理对象。 AVc
把BVc
弹出来(Present
出来),只须要AVc
继承WHPopViewController
,Present
调用代码也和以前同样(WHPopViewController
中重写该方法)。spa
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
复制代码
Ps.
假如你同一个VC
既须要Push
的转场效果,也须要Present
的转场效果,你能够修改上面的方法,增长一个BOOL isPushAnimation
的参数。code
Github连接:
######以为不错就点个赞吧😀😀cdn