2011-07-29 37 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

相关问题