<分区>
我有一个 TableView,里面有一个static cell,我想在按下按钮时展开它。单元格内有一个容器 View ,约束 已正确设置,但我不确定如何为单元格扩展设置动画,因为它需要我刷新 < strong> TableView 更新约束并展开单元格。
目前,当我调用 expandContainerView
时,它没有动画,因为我正在调用 self.tableView.reloadData
。
这是我用来展开单元格的代码
@objc private func expandContainerView(notification: NSNotification) {
self.view.layoutIfNeeded()
UIView.animate(withDuration: 2.0, delay: 0.0, options: .curveEaseOut, animations: {
self.containerHeightConstraint.constant = 410
self.view.layoutIfNeeded()
self.tableView.reloadData()
}, completion: nil)
}
这是我在索引代码处每一行的高度
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}