0

画像配列のアニメーションがありますが、これは連続ループです。1つのループだけを循環して、最後のフレームで停止するにはどうすればよいですか?

- (void) balloonAnimation
{
    NSMutableArray *balloonAnimationImages = [NSMutableArray arrayWithCapacity:27];

   for (NSInteger i = 0; i < 27; i++) {
       NSString *nameOfImage = [NSString stringWithFormat:@"balloons%d.png", i+1];
       UIImage *image = [UIImage imageNamed:nameOfImage];
       [balloonAnimationImages addObject:image];       
    }

    //animate here
    self.imgBalloon.animationImages = balloonAnimationImages;
    self.imgBalloon.animationDuration = 5.0f;
    [self.imgBalloon startAnimating];    
}
4

2 に答える 2

3

これを試して:

self.imgBaloon.animationRepeatCount = 1;

image編集:@Elliott Perryが彼の回答で述べたように、最後のフレームをプロパティに割り当てる必要があります。コードは次のとおりです。

self.imgBalloon.animationImages = balloonAnimationImages;
self.imgBalloon.animationDuration = 5.0f;
self.imgBaloon.animationRepeatCount = 1;
self.imgBaloon.image = [balloonAnimationImages lastObject];
[self.imgBalloon startAnimating]; 
于 2013-03-23T16:40:46.683 に答える
3

からUIImageViewアニメーションを最後のフレームで停止できますか?

UIImageViewクラスのimageプロパティには、次のドキュメントがあります。「animationImagesプロパティにnil以外の値が含まれている場合、このプロパティの内容は使用されません。」

したがって、iOS4 +でアニメーションの最後のフレームを保持する秘訣は、最初にimageプロパティをその最後のフレームに設定し(animationImagesがまだnilの場合)、次にanimationImagesプロパティを設定してstartAnimatingを呼び出すことです。アニメーションが完了すると、imageプロパティが表示されます。コールバック/デリゲートは必要ありません。

于 2013-03-23T17:37:03.430 に答える