場景
項目中碰見一個場景,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