我有一个小棋盘游戏,除了向对手展示最后一步外,一切都已完成。
我想做的是:
第1步:隐藏所有碎片
第二步:动画移动
第三步:再次显示现有作品
我已经尝试过,
[UIView animateWithDuration:5.00 delay:0.5
options:UIViewAnimationOptionCurveEaseOut //4
animations:^{
for (int i = 0; i<[_piecePlayer1 count]; i++) {
[[_piecePlayer1 objectAtIndex:i] hide];
[[_piecePlayer2 objectAtIndex:i] hide];
}
}
completion:^(BOOL finished){
}];
隐藏就是这样完成的。
-(void)hide{
CATransition *animation = [CATransition animation];
animation.type = kCATransitionFade;
animation.duration = 0.4;
[self.layer addAnimation:animation forKey:nil];
self.hidden = YES;
}
问题:
第 1 步工作正常,但如果我跳过第 2 步并只是尝试在完成 block 中显示片段
,即使我放置了一个带有延迟的嵌套动画 block ,它也会立即出现。
我如何逐步实现这一点,在第一个动画完成后执行其他动画?
感谢 danielquokka
和
特别感谢这个Repeat Animation
最佳答案
我认为核心问题是隐藏属性不可设置动画。而是使用可以动画的 alpha 属性。但我不明白你为什么要在这里使用 CATransition。以下代码将淡出片段,短暂延迟,然后淡入。
[UIView animateWithDuration:5.00
delay:0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
for (int i = 0; i<[_piecePlayer1 count]; i++) {
_piecePlayer1[i].alpha = 0.0;
_piecePlayer2[i].alpha = 0.0;
}
}
completion:^(BOOL finished){
[UIView animateWithDuration:5.00
delay:0.5
options:UIViewAnimationOptionCurveEaseIn
animations:^{
for (int i = 0; i<[_piecePlayer1 count]; i++) {
_piecePlayer1[i].alpha = 1.0;
_piecePlayer2[i].alpha = 1.0;
}
}
completion:^(BOOL finished){}
}];
}];
关于ios - ImageView 动画步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26943291/