从this堆栈示例中,我想出了如何为命名约束的常量参数设置动画。它工作正常,但我遇到了一个我没有找到解决方案的问题。我为动画设置了UIViewAnimationOptionBeginFromCurrentState选项,并且通过IBAction方法希望能够切换动画的最终状态,即使在动画期间也是如此。这是代码:
- (IBAction)animate:(id)sender {
self.brownViewHeightConstraint.constant = self.expanded ? 100.f : 390.f;
[self.brownView setNeedsUpdateConstraints];
self.expanded = !self.expanded;
[UIView animateWithDuration: 1.0
delay: 0
options: UIViewAnimationOptionBeginFromCurrentState
animations: ^{
[self.brownView layoutIfNeeded];
}
completion:^(BOOL finished) {
}
];
}
动画不支持 UIViewAnimationOptionBeginFromCurrentState 选项。如何使用AutoLayout完成此行为?