gpt4 book ai didi

ios - iOS 中动画图像的最佳实践 - UIImage 或 UIImageView?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:39:56 24 4
gpt4 key购买 nike

如果这个问题有点主观,我很抱歉,但我找不到关于该主题的任何信息。

问题很简单:

以下哪个选项是“最佳”(即最佳性能)。无论选择哪种解决方案,我都想在 UIImageView 中显示图像。

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 解决方案在循环次数等方面提供了更大的灵 active ,但我想要一个无限动画,所以在这种情况下这无关紧要。

最佳答案

在您描述的两个选项中,animatedImageNamed 方法比尝试使用 animationImages 更好。原因是如果图像系列太长或宽度和高度太大,animationImages 方法会使您的设备崩溃。问题是 animationImages 会以惊人的速度消耗内存,而 animatedImageNamed API 具有更好的内存限制。就 CPU 使用率和内存使用率而言,这两种方法实际上都不是“最佳”,因为有 significantly better可用的实现。

关于ios - iOS 中动画图像的最佳实践 - UIImage 或 UIImageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32781415/

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