iOS - 取消约束动画

标签 ios xcode6 autolayout uiviewanimation

我以通常的方式为约束设置动画:

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/

相关文章:

ios - 动态设置 ScrollView 的内容大小不起作用

swift - 使用 NSMetadataQuery 搜索文件什么都不做

ios - 自动布局有问题——简单的计算器应用程序

iphone - 从 5 月 1 日起 - iPhone 5 支持 - 那么应用商店支持的最低 iOS 版本是多少?

ios - 嵌套的 UIScrollViews 和事件路由

iOS 8 UIView 没有得到更新的问题

objective-c - iOS 5 : WebKit discarded an uncaught exception 中的新错误

xcode6 - 无法与主可执行文件链接

swift - 一起使用 CocoaPods 和 @IBDesignable

ios - 使用 NSLayoutAnchor 在两个标签之间创建约束?