【发布时间】:2025-12-08 21:10:02
【问题描述】:
我有以下简单的 UIImageView 动画:
-(void) setupTheAnimation {
self.imgView.animationImages = imagesArr;
[self.imgView setAnimationRepeatCount:-1];
self.imgView.animationDuration =0.9;
[self.imgView startAnimating];
[self performSelector:@selector(stopTheAnimation) withObject:nil afterDelay:4.0];
}
-(void) stopTheAnimation {
[self.imgView stopAnimating];
}
但是当动画停止时我遇到了一个问题我不知道它停止的最后一帧是什么!所以动画的结局一点都不流畅。
所以我需要:
1)知道动画结束的最后一帧是什么,所以我将它设置为动画的最后一个图像,这会导致平滑停止。
2)逐渐停止此动画,即在停止之前更改其持续时间以先减慢然后停止。
【问题讨论】:
-
我想说这需要在
UIImageView的子类上实现为自定义动画属性,您可以在其中将图层的内容重复设置为传入的图像数组中的图像提供定时功能。不会太难,但我认为使用UIImageView的animationImages实现缓和效果是不可能的。
标签: iphone ios objective-c uiimageview