自定义解除没有segue的过渡

时间:2015-05-30 22:01:16

标签: ios swift uiviewcontroller uinavigationcontroller

我已经看到过类似主题的各种问题/答案,但它们似乎都不是最新的。

如果我只是使用pushViewController来呈现具有自定义转换但没有segue的视图控制器,那么指定dismiss转换的正确方法是什么,我应该在哪里放置动画代码?

推送和初始转换:

let tr = CATransition();
tr.duration = 0.35;
tr.type = kCATransitionPush;
tr.subtype = kCATransitionFromTop;
self.navigationController!.view.layer.addAnimation(tr, forKey: kCATransition);

self.navigationController?.pushViewController(vc, animated: false);

1 个答案:

答案 0 :(得分:0)

您设置推送动画的方式已过时。 从iOS 7开始,有UINavigationControllerDelegate方法允许您返回自定义动画对象。

方法签名为-navigationController: animationControllerForOperation: fromViewController: toViewController` of `UINavigationControllerDelegate

有关详情,请访问check the docs