2011-07-29 5 views
0

4つの異なる画像でアニメーションのシリーズを行う必要があります。画像は順番に並べられます。最初の画像の動きから始まり、停止すると2番目の画像が移動し、同様に他の画像が続きます。誰か助けてくれますか?事前に異なる画像で一連のアニメーションを次々と使用する

おかげ

パンカジ

回答

[UIView animateWithDuration:2.0 
       animations:^{ 
        ballon1.center = CGPointMake(260, 50); 
       } 
       completion:^(BOOL finished){ 

        [UIView animateWithDuration:1.5 
             animations:^{ 
              ballon2.center = CGPointMake(260, 140); 
             } 
             completion:^(BOOL finished){ 
               [UIView animateWithDuration:1.0 
                   animations:^{ 
                    ballon3.center = CGPointMake(260, 230); 
                   } 
                   completion:^(BOOL finished){ 
                    [UIView animateWithDuration:1.0 
                        animations:^{ 
                         ballon4.center = CGPointMake(260, 320); 
                        } 
                        completion:^(BOOL finished){ 
                         ; 
                        }]; 
                   }]; 

              } 
             ]; 

       }]; 

答えて

1

あなたはこのような何か行うことができます。

[UIView animateWithDuration:1 animations:^{ 
    self.image1.frame = [self frameForImage1]; 
} completion:^(BOOL finished){ 
    [UIView animateWithDuration:1 animations:^{ 
     self.image2.frame = [self frameForImage2]; 
    } completion:^(BOOL finished){ 
     // etc. for images 3 and 4 
    }]; 
}]; 

をそれとも、むしろbeginAnimations:context:commitAnimationを使用してアニメーションにしてください場合は、あなたが各画像をアニメーション化するために一緒にセレクタの一連の連鎖にsetAnimationDelegate:setAnimationDidStopSelector:を使用することができます。

+0

ありがとうcduhn ...これは私が探していたものです – pankaj

0

私はあなたが数える...ので、あなたがこの

UIImageView *animView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 855, 768, 92)]; 
animView.animationImages = [NSArray arrayWithObjects: 
        [UIImage imageNamed:@"01.jpg"], 
        [UIImage imageNamed:@"02.jpg"], 
        [UIImage imageNamed:@"03.jpg"],nil]; 



// all frames will execute in 1.5 seconds 
animView.animationDuration = 7; 

// repeat the annimation forever 
animView.animationRepeatCount = 0; 

// start animating 
[animView startAnimating]; 

// add the animation view to the main window 
[webView addSubview:animView]; 
を使用することができます場合は、時間とともにイメージアニメーションを求めていると思います

希望すると、これが役立ちます。

+0

いいえ私はこれを求めていません。私は4種類の画像を持っており、それらを次々に動かす必要があります。これらの画像は、互いに異なり、異なる場所に置かれます。すべての画像は、画像が停止する前に移動する必要があります – pankaj

関連する問題