在A Beginner’s Guide to Animated Custom Segues in iOS 8通過自定義Segue來達(dá)到自定義轉(zhuǎn)場(chǎng)動(dòng)畫的效果爆办,但是這種做法有個(gè)非常大的缺點(diǎn),目標(biāo)ViewController的viewWillAppear
和viewDidAppear
會(huì)調(diào)用兩次
第一次window?.insertSubview(destView, aboveSubview: sourceView)
引起的
第二次
self.sourceViewController.presentViewController(self.destinationViewController, animated: false, completion: nil)
引起的
在iOS Animation Tutorial: Custom View Controller Presentation Transitions提到另一種自定義轉(zhuǎn)場(chǎng)動(dòng)畫卻不會(huì)引起上述該問題
根據(jù)這篇教程,寫了彈窗動(dòng)畫的Demo:
CustomPresentaionTranisitions