1

我正在尝试在 iPhone 上做一个简单的动画,然后让它在完成后停止。我目前使用的代码是:

NSArray *imageArray = [[NSArray alloc] initWithObjects:
                           [UIImage imageNamed:@"init_lay1.png"],
                           [UIImage imageNamed:@"init_lay2.png"],
                           [UIImage imageNamed:@"init_lay3.png"],
                           [UIImage imageNamed:@"init_lay4.png"],
                           [UIImage imageNamed:@"init_lay5.png"],
                           [UIImage imageNamed:@"init_lay6.png"],
                           [UIImage imageNamed:@"init_lay7.png"],nil];

    imageViewArms.animationImages = imageArray;
    imageViewArms.animationDuration = 0.23;
    imageViewArms.contentMode = UIViewContentModeBottomLeft;
    imageViewArms.animationRepeatCount = 0.0;
    [imageViewArms startAnimating];

一旦完成,我不确定如何停止它。有任何想法吗?谢谢。

4

2 回答 2

3

要在动画完成后停止动画,您应该使用:

imageViewArms.animationRepeatCount = 1;

不是:

imageViewArms.animationRepeatCount = 0;

animationRepeatCount设置为 0 意味着动画将被循环播放。将其设置为 1 意味着它将只播放一次。

于 2011-11-25T19:02:55.110 回答
2

-[UIImageView 停止动画]?

于 2010-01-03T00:40:37.753 回答