使用自定义动画关闭视图控制器? [英] Dismiss view controller with custom animation?
本文介绍了使用自定义动画关闭视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用这行代码来解除我的视图控制器 self.dismiss(animated:true,completion:nil)
,但我不喜欢当前的动画。相反,我想从左向右滑动。下面是我尝试测试动画,但不起作用。
I am using this line of code to dismiss my view controller self.dismiss(animated: true, completion: nil)
, but I do not like the current animation. Instead I want to slide from left to right. Below is my attempt to test out an animation, but does not work.
UIView.animate(withDuration: 1.0, delay: 0.0, options: UIViewAnimationOptions.curveEaseIn, animations: {
let transition = CATransition()
transition.duration = 10
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromLeft
self.view.layer.add(transition, forKey: kCATransition)
self.dismiss(animated: false, completion: nil)
}, completion: nil)
推荐答案
let transition: CATransition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionReveal
transition.subtype = kCATransitionFromRight
self.view.window!.layer.add(transition, forKey: nil)
self.dismissViewControllerAnimated(false, completion: nil)
这篇关于使用自定义动画关闭视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文