开发者

how to stop my animation on the last image?

I'm trying to run this animation which is working fine, but I want the last number to stay 开发者_运维知识库on the screen. currently it runs through the array then disappears.. is there anyway to stop the animation on the number that is passed in?

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


}


According to UIImageView startAnimating: How do you get it to stop on the last image in the series? the image that is shown after the animation ends is given in the "image" property. So something like this should do the trick:

animationArray.image = [imagesForAnimation lastObject];


        for (int counter=1; counter<number; counter++) {
        ...
        }
        [imagesForAnimation addObject:[UIImage imageNamed:@"FlapMoving1.png"]];
        [imagesForAnimation addObject:[UIImage imageNamed:[NSString stringWithFormat:@"Flap%i.png", number]]];

iterating to the all images but the last (counter) and then adding the last image to the animation array should help. tell me how it works.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜