Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 快速图像开放动画_Ios_Swift_Animation - Fatal编程技术网

Ios 快速图像开放动画

Ios 快速图像开放动画,ios,swift,animation,Ios,Swift,Animation,我想做以下全屏图像动画在Swift。单击项目时打开全屏图像的动画 您能帮助我并建议如何完成此操作吗?您需要在变换动画动作中使用CATTransformM3DMakeScale进行缩放。然后您必须使用自定义UIViewControllerAnimatedTransitioning 创建一个类AnimateTransition 然后在viewController中执行模型转换,如 cell = collectionView.cellForItem(at: indexPath) vc.

我想做以下全屏图像动画在Swift。单击项目时打开全屏图像的动画


您能帮助我并建议如何完成此操作吗?

您需要在变换动画动作中使用CATTransformM3DMakeScale进行缩放。

然后您必须使用自定义UIViewControllerAnimatedTransitioning

创建一个类AnimateTransition

然后在viewController中执行模型转换,如

    cell = collectionView.cellForItem(at: indexPath)
    vc.transitioningDelegate = self
    vc.modalPresentationStyle = .custom
    DispatchQueue.main.async {
        self.present(vc, animated: true, completion: nil)

    }
然后在viewController类中添加这些委托

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return AnimateTransition(withDuration: 0.5, forTransitionType: .Dismissing, originFrame: (self.cell?.frame)!, collectionView: collectionView)
}

func animationController(forPresented presented: UIViewController,
                         presenting: UIViewController,
                         source: UIViewController)
    -> UIViewControllerAnimatedTransitioning? { 
    return AnimateTransition(withDuration: 0.5, forTransitionType: .Presenting, originFrame: (self.cell?.frame)!, collectionView: collectionView)
}

这将解决您的问题

您的图像是否放在“收藏”视图中。如果我是正确的,那么您希望添加类似于iPhone中应用程序打开动画的动画。如果我错了,请纠正我是的,图像在collectionview中。是的,我想做类似于应用程序打开动画的动画。拉胡尔:谢谢你的回答,它成功了。我想给第二个视图控制器的其他项目设置动画,你知道怎么做吗?你可以使用动画。是的,我用过,但我希望两个动画一起发生。图像打开全屏和新viewcontrollercan中的动画您可以给我一个动画应该如何使用一些GIF的示例。我希望动画完全像这样:当图像打开全屏时,顶部栏向上滑动并消失新viewcontrollers顶部栏从右侧滑入,底部面板向上滑动。所有这些动画一起发生。
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return AnimateTransition(withDuration: 0.5, forTransitionType: .Dismissing, originFrame: (self.cell?.frame)!, collectionView: collectionView)
}

func animationController(forPresented presented: UIViewController,
                         presenting: UIViewController,
                         source: UIViewController)
    -> UIViewControllerAnimatedTransitioning? { 
    return AnimateTransition(withDuration: 0.5, forTransitionType: .Presenting, originFrame: (self.cell?.frame)!, collectionView: collectionView)
}