gpt4 book ai didi

ios - 使用自定义动画关闭 View Controller ?

转载 作者:IT王子 更新时间:2023-10-29 05:38:42 30 4
gpt4 key购买 nike

我正在使用这行代码关闭我的 View Controller 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)

最佳答案

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)

关于ios - 使用自定义动画关闭 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38799143/

30 4 0
文章推荐: ios - Swift:无法分配给类型为 'AnyObject?!' 的不可变表达式
文章推荐: javascript - TinyMCE - 允许文本作为 和/或 的直接子元素