我在viewController
- (void)moveAnimating
{
[UIView animateWithDuration:2.0f animations:^{
_backgroundView.center = CGPointMake(self.center.x , self.center.y - kMoveDistanceHeight);
} completion:^(BOOL finished) {
if (_backgroundView.animating)
{
[_backgroundView moveAnimating];
}
}];
}
我希望在viewController
viewWillDisappear
:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
_backgroundView.animating = NO;
[_backgroundView.layer removeAllAnimations];
}
因为动画与dismissViewcontrollerAnimation
冲突。
问题:
[_backgroundView.layer removeAllAnimations];
不行......
如何停止动画?
帮助我,谢谢。
答案 0 :(得分:2)
您正在取消动画:
[_backgroundView.layer removeAllAnimations];
但是你可能会忘记导入QuartzCore.h:
#import <QuartzCore/QuartzCore.h>
如果没有帮助尝试这个:
[CATransaction begin];
[_backgroundView.layer removeAllAnimations];
[CATransaction commit];
如果没有帮助,请尝试将此行添加到上面的代码中:
[CATransaction flush];