// 返回負責轉場的控制器對象 func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? { return PopoverPresentationController(presentedViewController: presented, presentingViewController: presenting) } // 返回提供modal動畫的對象 func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresented = true return self } // 返回提供dismiss動畫的對象 func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresented = false return self } // 動畫時長 func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { return 1.2 } // 轉場動畫實現函數 func animateTransition(transitionContext: UIViewControllerContextTransitioning) { }
// 設置轉場動畫代理vc.transitioningDelegate = self// 將轉場動畫設置為自定義vc.modalPresentationStyle = UIModalPresentationStyle.Custom
新聞熱點
疑難解答