【发布时间】:2012-03-04 11:17:49
【问题描述】:
我在按钮触摸后运行动画。如果用户在当前动画完成之前触摸按钮,我希望新动画等到当前动画完成。我该怎么做?
【问题讨论】:
我在按钮触摸后运行动画。如果用户在当前动画完成之前触摸按钮,我希望新动画等到当前动画完成。我该怎么做?
【问题讨论】:
使用 UIView 的 animateWithDuration 包装器的完成变体嵌套它,如下所示:
[UIView animateWithDuration:1.00 animations:^{
//animate first!
}
completion:^(BOOL finished) {
[UIView animateWithDuration:1.00 animations:^{
//animate the second time.
}];
}];
或者只是设置一个动画从当前状态继续:
[UIView animateWithDuration:1.00
delay:0.00
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
//animate
}
completion:^(BOOL finished){
}];
【讨论】:
我总是用这个链接我的动画:
[self performSelector:@selector(animationDone) withObject:nil afterDelay:1.0];
【讨论】: