2011-07-29 81 views
0

我需要在4個不同的圖像上進行一系列動畫。圖像按順序排列。它將從第一個圖像的移動開始,當它停止時,第二個圖像將移動,其他人將跟隨。有人可以幫幫我嗎?一個接一個地在不同的圖像上使用一系列動畫

在此先感謝

潘卡

回答

[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

相關問題