-(void)methodXXXX {
[UIView animateWithDuration:11 animations:^{
//...some animation changes...
} completion:^(BOOL finished) {
[_fallBtn removeFromSuperview];
_fallBtn = nil;
}
}];
}
我通过
-viewDidAppear
调用此方法,而直接调用完成块。为什么?我错过了什么奇怪的东西吗?
我发现了另一件事:
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = YES; //If set YES, it will directly call -animationDidStop method; if NO, the animation execute while never call -animationDidStop
pathAnimation.duration = 10;
pathAnimation.delegate = self; //here I implement the -animationDidStop method
最佳答案
使用以下代码。
-(void)viewDidAppear:(BOOL)animated {
[self performSelector:@selector(methodXXXX) withObject:nil afterDelay:0.1f];
}
-(void)methodXXXX {
[UIView animateWithDuration:11 animations:^
//...some animation changes...
} completion:^(BOOL finished) {
[_fallBtn removeFromSuperview];
_fallBtn = nil;
}];
}
关于ios - UIView动画完成块立即执行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30938314/