冻结动画的最后一帧新代码?
我正在尝试冻结动画的最后一帧。以下代码曾经有效,但是在更新到 iOS 后它不再有效。我怎样才能编写这段代码以使最后一个图像保留在屏幕上?
animation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"watermelondrop2.png"],
[UIImage imageNamed:@"watermelondrop4.png"],
[UIImage imageNamed:@"watermelondrop6.png"],
[UIImage imageNamed:@"watermelondrop8.png"],
[UIImage imageNamed:@"watermelondrop10.png"],
[UIImage imageNamed:@"watermelondrop12.png"],
[UIImage imageNamed:@"watermelondrop14.png"],
[UIImage imageNamed:@"watermelondrop15.png"], nil];
animation.animationDuration = .8;
animation.animationRepeatCount = 1;
[animation startAnimating];
[self playwatermelondropsound];
[self.view addSubview:animation];
animation.image = [UIImage imageNamed:@"watermelondrop16.png"];
I'm trying to freeze the last frame of an animation. The following code used to work, however after an update to iOS it no longer works. How can I write this code so that the last image stays on the screen?
animation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"watermelondrop2.png"],
[UIImage imageNamed:@"watermelondrop4.png"],
[UIImage imageNamed:@"watermelondrop6.png"],
[UIImage imageNamed:@"watermelondrop8.png"],
[UIImage imageNamed:@"watermelondrop10.png"],
[UIImage imageNamed:@"watermelondrop12.png"],
[UIImage imageNamed:@"watermelondrop14.png"],
[UIImage imageNamed:@"watermelondrop15.png"], nil];
animation.animationDuration = .8;
animation.animationRepeatCount = 1;
[animation startAnimating];
[self playwatermelondropsound];
[self.view addSubview:animation];
animation.image = [UIImage imageNamed:@"watermelondrop16.png"];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我花了 40 分钟来解决您的问题,而且非常简单:
有两种方法可以实现您想要的效果:
默认
图像。或者只是这样做,
猜猜它会开始工作,因为我已经测试过它。 :)
I spend 40 my minutes to resolve your problem, and it was just so simple:
There are two way you can achieve what you want:
default
image.or just do this,
And guess what it'll start working, as I have tested it. :)
这
是显示图像跳跃的示例,这可能会帮助你
}
This is the example to show the image jumping i thick this may help u
你的代码对我来说看起来很好,除了当我这样做时,我通常设置
UIImageView
的.image
属性 BEFORE 我告诉UIImageView
开始动画。另外,将[UIImage imageNamed:@"watermelondrop16.png"]
添加到.animationImages
数组的末尾。也许这会解决你的问题。希望有帮助!Your code looks fine to me, except when I do it, I usually set the
.image
property of theUIImageView
BEFORE I tell theUIImageView
to start animating. Also, add[UIImage imageNamed:@"watermelondrop16.png"]
to the end of your.animationImages
array. Maybe that will fix your problem. Hope that Helps!