2014-02-10 33 views
0

我做一个application.In是我做动画的UIImageView显示像下面如何做动画的UIImageView并停止剩余过程

UIImageView * fearthersanimate = nil; 
    [fearthersanimate setCenter:sender.center]; 

    fearthersanimate = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 120,200)]; 
    [fearthersanimate setCenter:CGPointMake(sender.center.x, sender.center.y)]; 
    fearthersanimate .animationImages = [NSArray arrayWithObjects: 
             [UIImage imageNamed:@"water_can_1.png"], 
             [UIImage imageNamed:@"water_can_2.png"],[UIImage imageNamed:@"water_can_3.png"], 
             [UIImage imageNamed:@"water_can_4.png"],[UIImage imageNamed:@"water_can_5.png"], 
             [UIImage imageNamed:@"water_can_6.png"],[UIImage imageNamed:@"water_can_7.png"], 
             [UIImage imageNamed:@"water_can_8.png"], 
             nil]; 
    fearthersanimate.animationDuration = 1.0f; 
    fearthersanimate.animationRepeatCount = 1; 
    [self.view addSubview: fearthersanimate]; 
    [fearthersanimate startAnimating]; 

不同的形象,但其余操作开始之前但是我需要先做这个动画,直到我需要停止剩下的过程。

回答

0

您可以使用UIView动画块。例如:

[UIView animateWithDuration:0.5 animations:^{ 

} completion:^(BOOL finished) { 

}]; 

将剩余的进程放到完成块中。

0

这些动画是异步执行的,所以你只需要与异步战斗异步。

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(feathersanimate.animationDuration * NSEC_PER_SEC)); 
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
    // Remaining logic 
}); 
1

您可以使用其他方法调用其余方法的操作,并在您为图像设置动画时间的相同延迟后调用它。 下面是代码行,通过它可以一定的时间间隔

[self performSelector:@selector(restOfOperations) withObject:nil afterDelay:1.0]; 

// restOfOperations方法认定中/实施后调用其他方法

-(void)restOfOperations 
    { 
    //your code you want to perform after image animation 
    }