gpt4 book ai didi

ios - dismissViewControllerAnimated 自定义动画

转载 作者:搜寻专家 更新时间:2023-10-31 23:04:48 26 4
gpt4 key购买 nike

我试图用自定义动画调用 dismissViewControllerAnimated,但它似乎不起作用。

当我像这样呈现 View Controller 时:

        cameraUI = UIImagePickerController()
cameraUI.delegate = self
cameraUI.sourceType = UIImagePickerControllerSourceType.Camera
cameraUI.mediaTypes = [kUTTypeImage]
cameraUI.allowsEditing = false
cameraUI.showsCameraControls = false

var translate = CGAffineTransformMakeTranslation(0.0, 71.0); //This slots the preview exactly in the middle of the screen by moving it down 71 points
cameraUI.cameraViewTransform = translate;

var scale = CGAffineTransformScale(translate, 1.333333, 1.333333);
cameraUI.cameraViewTransform = scale;


var transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionMoveIn
transition.subtype = kCATransitionFromLeft
self.view.window?.layer.addAnimation(transition, forKey: nil)

self.presentViewController(cameraUI, animated: false, completion: nil)

效果很好。它可以正确滑入。

然后我去驳回它:

            var transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionMoveIn
transition.subtype = kCATransitionFromRight
self.view.window?.layer.addAnimation(transition, forKey: nil)
cameraUI.dismissViewControllerAnimated(false, completion: nil)

它只是消失而根本没有动画。

有什么想法吗?

最佳答案

自定义呈现或关闭 View Controller 时发生的动画的方式不是在其背后提供过渡,而是自定义实际动画。为呈现的 View Controller 提供一个实现 animationControllerForPresentedController:presentingController:sourceController:transitioningDelegateanimationControllerForDismissedController:。现在动画 Controller 通过 animateTransition: 的实现全面负责动画。

关于ios - dismissViewControllerAnimated 自定义动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26834392/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com