Xcode - 使用PNG序列进行动画制作

时间:2018-03-07 04:35:23

标签: ios xcode animation after-effects

我用After Effects制作了一个动画,并将其作为PNG序列添加到我的Xcode项目中。这给我留下了一个包含164个图像的文件夹,我正在使用计时器进行动画制作。应用程序性能如何?我可以添加更多这样的动画吗?

1 个答案:

答案 0 :(得分:3)

如果它的图像, 首先在阵列中获取这些图像

 @IBOutlet weak var animatingImageView: UIImageView!
var imageList = [UIImage]()

现在调用函数

func playAnimation() {
    self.animatingImageView.animationImages = imageList
    self.animatingImageView.animationDuration = 2.0
    self.animatingImageView.startAnimating()
}

你可以使用

self.animatingImageView. animationRepeatCount

重复计数,

并且,如果你想在一段时间间隔之后停止它,可以使用计时器,并在计时器完成时

self.animatingImageView.stopAnimating()

以获得更好的表现:

尝试使用尺寸接近imageview的图像

尝试使用缓存图像

尝试使图像不透明