我以通常的方式为约束设置动画:
centerXsettingsBtnConstraint.constant = aValue;
[UIView animateWithDuration:.5
animations:^{
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
isAnimating = NO;}];
当我旋转设备时,我想取消这个动画并用新值更新约束。
我试着打电话
[self.view.layer removeAllAnimations];
但动画仍在继续,直到设备旋转结束。只有这样我才能使用新约束进行更新,但在旋转过程中屏幕上一团糟。
有没有办法取消约束动画?
最佳答案
您必须在每个 subview 上调用 remove.. 方法:
[self.view.layer removeAllAnimations];
我将使用 Swift:
for eachView in self.view.subviews {
eachView.layer.removeAllAnimations()
}
关于iOS - 取消约束动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31074938/