我是一个有用的助手,可以为您翻译。以下是我翻译的结果:
我正在尝试创建一个自定义CATransition,使得推送一个viewController的效果与模态展示的效果完全相同。
到目前为止,我已经为模态展示做了这个:
override func viewWillAppear(_ animated:Bool){
super.viewWillAppear(animated)
self.transition = CATransition()
self.transition.duration = 0.4
self.transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.transition.type = kCATransitionMoveIn
self.transition.subtype = kCATransitionFromTop
self.transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.navigationController?.view.layer.add(self.transition, forKey: nil)
}
这是关于解雇的内容。
override func viewWillDisappear(_ animated:Bool){
super.viewWillDisappear(animated)
self.transition.type = kCATransitionReveal
self.transition.subtype = kCATransitionFromBottom
self.navigationController?.view.layer.removeAllAnimations()
self.transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.navigationController?.view.layer.add(self.transition, forKey: nil)
}
这是我从导航控制器中推送它的方式
self.navigationController?.pushViewController(myViewController(), animated: false)
我拥有的与默认的UIViewController.present(vc, animated: true, completion: nil)动画并没有太大的区别,但是它们微妙地不同,尤其是缓动和退出动画。
有人知道我可以使用哪些确切的值来最接近我要寻找的动画吗?