我正在尝试使用以下代码在动画中增加自定义键盘的高度。但我无法弄清楚为什么会立即发生变化,忽略动画。
//In viewDidAppear
[self.view needsUpdateConstraints];
[UIView animateWithDuration:2 animations:^{
CGFloat _expandedHeight = 500;
NSLayoutConstraint *_heightConstraint = [NSLayoutConstraint
constraintWithItem: self.view
attribute: NSLayoutAttributeHeight
relatedBy: NSLayoutRelationEqual
toItem: nil
attribute: NSLayoutAttributeNotAnAttribute
multiplier: 0.0
constant: _expandedHeight];
[self.view addConstraint: _heightConstraint];
[self.view layoutIfNeeded];
}];