我正在尝试执行球爆破效果,以发挥顺序。接二连三。
我做了什么:
我用过的球体爆破效果
UIButton *ballButton = (UIButton *)[cell viewWithTag:10];
ballButton.imageView.animationImages = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"1.png"],
[UIImage imageNamed:@"2.png"],
[UIImage imageNamed:@"3.png"],
[UIImage imageNamed:@"4.png"],
nil];
ballButton.imageView.animationDuration = 1;
ballButton.imageView.animationRepeatCount = 1;代码上的这一行附加到集合视图单元格中的多个按钮。我把这些叫做ballbutton.imageview,像这样启动动画
[UIView animateWithDuration:1 delay:5 options:UIViewAnimationOptionCurveEaseOut animations:^{
NSIndexPath *path2 = [NSIndexPath indexPathForRow:x inSection:0];
UICollectionViewCell *cell = [ballContainer cellForItemAtIndexPath:path2];
UIButton *ballObject = (UIButton *) [cell viewWithTag:10];
[ballObject.imageView startAnimating];
} completion:^(BOOL b){
NSLog(@" here i call next animation of ball blast to execute ");
}];我嵌套了3个像这样的动画按钮。
发布于 2013-07-11 04:22:03
这样我就解决了我的问题。最初,我通过调用以下命令来启动动画
[self startAnim:index];而不是像这样实现这个StartAnim并解决问题。
-(void)StartAnim :(int)x{
NSIndexPath *path2 = [NSIndexPath indexPathForRow:x inSection:0];
UICollectionViewCell *cell = [ballContainer cellForItemAtIndexPath:path2];
UIButton *ballObject = (UIButton *) [cell viewWithTag:10];
[ballObject setBackgroundImage:nil forState:UIControlStateNormal];
ballObject.imageView.image = nil;
[ballObject.imageView startAnimating];
double delayInSeconds = 0.15;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
if(x-6>=0){
[self StartAnim :(x-6)];
}
});
}发布于 2013-07-07 09:41:50
首先,你为什么不为其他三个人制作一个大动画呢?UIView animateWithDuration:的特点是,它在给它的时间内执行动画块,也就是说,将框架从(200,200)设置为(0,0)将在一秒钟内(在您的情况下)按比例移动。但是UIImageView关于动画的属性是以这样的方式制作的,即动画已经为您完成了。
就我个人而言,我建议使用计时器,就像这样:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:ballObject.imageView.animationDuration
target:self
selector:@selector(performNextAnimation:)
userInfo:nil repeats:NO];
[ballObject.imageView startAnimating];在performNextAnimation方法中:
- (void) performNextAnimation{
[timer invalidate]; // you have to access the timer you've scheduled with the animation
timer = nil;
/* code for starting the next animation */
}https://stackoverflow.com/questions/17504712
复制相似问题