[英]smooth UIImageView animation for multiple images
I have used animation on an UIImageView
to animate 36 images like this: 我在
UIImageView
上使用了动画来对36张图像进行动画处理,如下所示:
-(void) kickOffTheAnimation {
self.imgView.animationImages = imagesArr;
[self.imgView setAnimationRepeatCount:HUGE_VALF];
self.imgView.animationDuration =0.9;
[self.imgView startAnimating];
}
and my viewDidLoad
method is simply as: 我的
viewDidLoad
方法很简单:
NSMutableArray *imagesArr = [[NSMutableArray alloc] init];
for(int i =0; i<35; i++) {
[imagesArr addObject:[UIImage imageNamed: [NSString stringWithFormat:@"img%i@2x.png",i]]];
}
[self kickOffTheAnimation];
However, there is a small glitch, the animation is not smooth when it reaches the final image and repeats the animation from the first image, how can I fix this problem? 但是,有一个小故障,到达最终图像并从第一幅图像开始重复动画时,动画不流畅,如何解决此问题?
EDIT: 编辑:
the exact problem is there is a milliseconds hang happens after reaching img35.png and showing img0.png 确切的问题是到达img35.png并显示img0.png后发生毫秒级挂起
I have sometimes noticed a very small loop delay with a larger in memory image array. 有时,我注意到一个很小的循环延迟,而内存映像阵列更大。 It could be that some resource has to be reloaded.
可能是某些资源必须重新加载。 I have used
AVPlayer
in repeat mode with better luck for a small movie. 我已经在重复模式下使用
AVPlayer
,因为一部小电影的运气更好。 An actual movie might also compress better. 实际的电影可能还会压缩得更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.