1

アニメーション ブロックの操作に問題があります。最初のアニメーションで画像のアルファを変更して点滅させ、10秒後に消えるようにしようとしています。firstAnimation は次に secondAnimation に移動し、同じことを別の画像に対してのみ行います。その後、プロセスは無限に繰り返されます。

私はしばらくの間これに取り組んできましたが、それを無限に繰り返すことはできません。私が抱えていたもう 1 つの問題は、このアニメーション プロセスの遅延があったことです。そのため、オーディオ ファイルを再生するのに十分な時間である 20 秒後に開始されます。

- (void) firstAnimation {
            UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear;

            [UIView animateWithDuration:1.0 delay:10.0 options:options animations:^ 
            {
                    myImage.alpha = 0.0;
                    myImage.alpha = 1.0;

            }

                    completion:^(BOOL finished){

                    [self secondAnimation]; 
            }
             ];

    }

いつものように、助けてくれてありがとう。サンプルコードとチュートリアルを検索しましたが、基本的に上記のコードで行っていることしか見つかりませんでした。

4

2 に答える 2

1
animateImageWithCount:(int)aCount{
    if( aCount >= [imageArray count]){
        NSLog(@"Done all images");
        return;
    }

    UIImage *myImage = [ImageArray objectAtIndex:aCount];
    UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear;

    myImage.alpha = 0.0;
    [UIView animateWithDuration:1.0 delay:10.0 options:options animations:^{
        myImage.alpha = 1.0;
    }
    completion:^(BOOL finished){
        [self animateImageWithCount:(aCount+1)];
     }];
}
于 2011-12-23T05:36:23.280 に答える
1

アニメーションブロックの外側にアルファの初期値を設定し、ブロックの内側にアニメーション化する値のみを設定する必要があると思います。

UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear;
myImage.alpha = 0.0;
[UIView animateWithDuration:1.0 delay:10.0 options:options animations:^ 
        {
                myImage.alpha = 1.0;

        }
于 2010-10-14T13:01:34.903 に答える