Xcode 8 Swift3.0 转场动画的改变,旧版本的失效问题

我今天做了一个自定义转场控制器,可是怎么写,代理方法都是无效的,所以查找了相关资料后,发现代理方法的实现方法有了更新。

我写的这个是继承了UIViewControllerTransitioningDelegate,UIViewControllerAnimatedTransitioning

如果只更改frame的话 只继承UIViewControllerTransitioningDelegate 就可以。
一下是旧版本swift 2.n版本的

// 目的:改变弹出View的尺寸
    func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {
        
        let presentation = LXPPresentationController(presentedViewController: presented, presentingViewController: presenting)
        presentation.presentedFrame = presentedFrame
        
        return presentation
    }
    
    // 目的:自定义弹出的动画
    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        
        isPresented = true
        callBack!(presented : isPresented)
        
        return self
    }
    
    // 目的:自定义消失的动画
    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        
        isPresented = false
        callBack!(presented : isPresented)
        
        return self
    }

这是 swift 3.0 的

func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        
        let present = OrderPresentController(presentedViewController: presented, presenting: presenting)
        present.presentedFrame = presentedFrame
        
        return present
        
    }
    // 目的:弹出动画交给谁来管理

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        
        isPresented = true
        if animateCallBack != nil {
            animateCallBack!(isPresented)
        }
        
        return self
        
    }
    // 目的:消失动画交给谁来管理

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        isPresented = false
        if animateCallBack != nil {
            animateCallBack!(isPresented)
        }
        
        return self
    }

你可能感兴趣的:(Xcode 8 Swift3.0 转场动画的改变,旧版本的失效问题)