在iOS中的animation图像的最佳做法 – UIImage或UIImageView?

对不起,如果这个问题有点主观,但我找不到任何关于这个话题。

问题很简单:

以下哪一种select是“最好”的(即最佳性能)。 我想在UIImageView中显示图像,而不pipeselect的解决scheme。

self.imageView.image = [UIImage animatedImageNamed:@"imagename-" duration:2.0f]; 

要么

 self.imageView.animationImages = listOfMyImageNames; self.imageView.animationRepeatCount = 0; self.imageView.animationDuration = 2; [self.imageView startAnimating]; 

我知道UIImageView解决scheme提供了更多的循环数量的灵活性,但我想要一个无限的animation,在这种情况下无关紧要。

在你描述的两个选项中,animatedImageNamed方法比试图使用animationImages要好。 原因是如果一系列图像太长或者宽度和高度太大,animationImages方法会使设备崩溃。 问题是animationImages会以令人震惊的速度吃掉内存,而不是具有更好内存限制的animatedImageNamed API。 在CPU使用率和内存使用方面,这两种方法实际上都不是最好的,因为有更好的实现。