ViewController之间的滞后自定义过渡

时间:2019-08-31 04:15:49

标签: ios swift

所以我想自定义Viewcontroller Presentation,因为使用我的代码viewcontroller冻结了半秒钟,然后显示了其他viewcontroller

extension UIViewController {

func presentDetail (_ viewControllerToPresent : UIViewController) {
    let transition = CATransition()
    transition.duration = 0.3
    transition.type = .push
    transition.subtype = .fromLeft
    self.view.window?.layer.add(transition, forKey: kCATransition)

    present(viewControllerToPresent, animated: false, completion: nil)
}
}

1 个答案:

答案 0 :(得分:0)

对于自定义演示,您需要在presentedView上提供transitionDelegate,然后提供所需的动画师对象。

可能的最小实现似乎是在func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController?中提供UIPresentationController