开发者

Simple Sprite Animation on iPhone

I am trying to do a si开发者_如何学Cmple animation on the iPhone and then have it stop once it is finished. The code I am currently using is:

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];

I'm not sure of how to stop it once it is finished. Any ideas? Thanks.


To stop the animation once it is finished you should use:

imageViewArms.animationRepeatCount = 1;

not:

imageViewArms.animationRepeatCount = 0;

Setting the animationRepeatCount to 0 means that the animation wil be looped. Setting it to 1 means that it will be played only once.


-[UIImageView stopAnimating]?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜