要解决表视图底部约束不会动画/更改的问题,可以尝试以下方法:
UIView.animate(withDuration: 0.3) {
// 更新约束
tableViewBottomConstraint.constant = newBottomValue
// 强制更新约束
self.view.layoutIfNeeded()
}
// 更新约束
tableViewBottomConstraint.constant = newBottomValue
UIView.animate(withDuration: 0.3, animations: {
// 强制更新约束
self.view.layoutIfNeeded()
}, completion: nil)
// 开始更新
tableView.beginUpdates()
// 更新约束
tableViewBottomConstraint.constant = newBottomValue
// 结束更新
tableView.endUpdates()
以上是几种常见的解决表视图底部约束不会动画/更改的方法,根据具体情况选择适合的方法进行使用。
上一篇:表示图的数据结构
下一篇:表视图高度不正确地进行动画