2012-09-18 33 views
0

我有2个动画。第一个是应用程序加载时的第一个,第二个将保持用户体验的其余部分。IOS应用程序切换动画“A”与动画“B”在同一个地方

这是我想在其中加载应用程序加载时,简单地说

1)动画“A”的事情。 2)然后我想隐藏动画a“A”并用相同坐标上的动画“B”代替它3)动画“B”在任何其他时间或间隔30秒或45秒播放动画

动画一个

[UIView animateWithDuration:2.5 
         delay:2.0 
        options:UIViewAnimationCurveEaseIn 
       animations:^{[buhoButton setFrame:CGRectMake(91, 185, 130, 130)];}completion:nil]; 

动画乙

animation.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"Buho128x128_0.png"], 
            [UIImage imageNamed:@"Buho128x128_1.png"], 
            [UIImage imageNamed:@"Buho128x128_2.png"], 
            [UIImage imageNamed:@"Buho128x128_3.png"], 
            [UIImage imageNamed:@"Buho128x128_4.png"], 
            [UIImage imageNamed:@"Buho128x128_3.png"], 
            [UIImage imageNamed:@"Buho128x128_2.png"], 
            [UIImage imageNamed:@"Buho128x128_1.png"], 
            [UIImage imageNamed:@"Buho128x128_0.png"], nil]; 
[animation setAnimationRepeatCount:-1]; 
animation.animationDuration = 1; 
[animation startAnimating]; 

这可能吗?

回答

1

尝试把代码动画B插入动画A的completition块:

[UIView animateWithDuration:2.5 
        delay:2.0 
       options:UIViewAnimationCurveEaseIn 
      animations:^{[buhoButton setFrame:CGRectMake(91, 185, 130, 130)];} 
      completion:^(BOOL finished){/*Animation B code here*/;} 
]; 
+0

当A完成时,它开始动画B.现在,我面临着如何隐藏动画A一旦完成,只是动画B留在后面。 – Jiraheta

+0

当动画A完成时,您想要隐藏按钮吗?如果是这样,请设置buhoButton.hidden = YES;在完成块。 – ale84

+0

伙计!那就像魅力一样工作!非常感谢。 – Jiraheta

1

如果您想在动画B触发你可以使用一个CABAsicAnimation与removedOnCompletion在控制= YES动画A(放置在你的viewDidLoad)和removedOnCompletion = NO为动画B(放置你的tiggering事件处理的地方)。

+0

你有一个例子或一些剪辑,看看我会如何走这条路? – Jiraheta

+0

以下是Apple的MoveMe示例代码示例: CABasicAnimation * transformAnimation = [CABasicAnimation animationWithKeyPath:@“transform”]; transformAnimation.removedOnCompletion = YES; transformAnimation.duration = animationDuration; –