我正在尝试运行这个正常工作的动画,但我希望最后一个数字留在屏幕上。目前它通过数组运行然后消失..无论如何停止传递的数字上的动画?
- (void)playAnimationToNumber:(int)number{
NSMutableArray *imagesForAnimation = [[NSMutableArray alloc] initWithCapacity:0];
for (int counter=1; counter<=number; counter++) {
NSString *imageNameForFirstNumber = [NSString stringWithFormat:@"Flap%i.png", counter];
[imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving1.png"]];
[imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving2.png"]];
[imagesForAnimation addObject:[UIImage imageNamed:imageNameForFirstNumber]];
}
animationArray.animationImages = [NSArray arrayWithArray:imagesForAnimation];
animationArray.animationDuration = 1.2;
animationArray.animationRepeatCount = 1;
[animationArray startAnimating];
[self.view addSubview:animationArray];
[imagesForAnimation release];
}
答案 0 :(得分:0)
根据UIImageView startAnimating: How do you get it to stop on the last image in the series?,动画结束后显示的图像在“image”属性中给出。所以这样的事情应该可以解决问题:
animationArray.image = [imagesForAnimation lastObject];
答案 1 :(得分:0)
for (int counter=1; counter<number; counter++) {
...
}
[imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving1.png"]];
[imagesForAnimation addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Flap%i.png", number]]];
迭代到所有图像,但最后一个(计数器),然后将最后一个图像添加到动画数组应该有所帮助。告诉我它是如何工作的。