Ios Swift 3-动画序列停止时的性能检查

Ios Swift 3-动画序列停止时的性能检查,ios,animation,swift3,Ios,Animation,Swift3,我需要帮助,因为我在任何地方都找不到确切的例子来做我想做的事情 我想制作一个简单的png序列的动画,然后在完成后调用performsgue(这是我的主要问题) 所以我试过了 InitImage.animationImages = [ UIImage(named:"load1.png")!, UIImage(named:"load2.png")!, UIImage(named:"load3.png")!, /* 20 more images... */ ] InitIm

我需要帮助,因为我在任何地方都找不到确切的例子来做我想做的事情

我想制作一个简单的png序列的动画,然后在完成后调用performsgue(这是我的主要问题)

所以我试过了

InitImage.animationImages = [
    UIImage(named:"load1.png")!,
    UIImage(named:"load2.png")!,
    UIImage(named:"load3.png")!,
 /* 20 more images... */
]

InitImage.animationDuration = 2.5
InitImage.animationRepeattCount = 1
InitImate.startAnimating()
因此,它设置了动画,但调用segue太早了。我发现我应该使用

UIView.animate(withDuration : ...)
但我找不到一个用Swift3编写的例子,它可以为一系列文件制作动画

有人能告诉我怎么走吗?
谢谢。

我认为最简单的方法就是做一个计时器

Timer.scheduledTimer(timeInterval: InitImage.animationDuration * Double(InitImage.animationImages?.count ?? 0), target: self, selector: #selector(push), userInfo: nil, repeats: false)
和选择器

func push() {
.... perform segue
}

我认为最简单的方法是做一个计时器

Timer.scheduledTimer(timeInterval: InitImage.animationDuration * Double(InitImage.animationImages?.count ?? 0), target: self, selector: #selector(push), userInfo: nil, repeats: false)
和选择器

func push() {
.... perform segue
}

最简单的选择是将performSelector与afterDelay一起使用,因为self是@objc UIViewController:

self.perform(#selector(segueToDetailViewController), with: self, afterDelay: InitImage.animationDuration)
和选择器:

func segueToDetailViewController() {
    self.performSegue( ... etc ... )
}

上面的代码没有将动画持续时间乘以图像数,因为当我运行代码时,我发现所有图像的动画持续时间都是2.5秒。

最简单的选择是使用带afterDelay的PerformSelect,因为self是一个@objc UIViewController:

self.perform(#selector(segueToDetailViewController), with: self, afterDelay: InitImage.animationDuration)
和选择器:

func segueToDetailViewController() {
    self.performSegue( ... etc ... )
}

上面的代码没有将动画持续时间乘以图像数,因为当我运行代码时,我发现所有图像的动画持续时间都是2.5秒。

我认为没有UIView animateWithDuration变体可以让你像动画GIF一样循环浏览一系列静止图像。您必须使用当前使用的代码。Axel的解决方案是创建一个计时器,计算谁的持续时间,以便在动画完成时触发计时器。我认为没有UIView animateWithDuration变体可以让你像动画GIF一样循环浏览一系列静止图像。您必须使用当前使用的代码。Axel的解决方案是创建一个计时器,计算谁的持续时间,以便在动画完成时触发计时器,这可能是最好的方法。