我正在使用这行代码来关闭我的视图控制器self.dismiss(animated: true, completion: nil)
,但我不喜欢当前的动画。相反,我想从左向右滑动。下面是我尝试测试动画,但不起作用。
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)
答案 0 :(得分:37)
let transition: CATransition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
transition.type = CATransitionType.reveal
transition.subtype = CATransitionSubtype.fromRight
self.view.window!.layer.add(transition, forKey: nil)
self.dismiss(animated: false, completion: nil)