I've searched on Stack Overflow and other sources but despite similar problem title I can't find a solution.
What I want to do is to animate UITableViewCell
height
together with content. Here is an example:
There is a blue panel in the middle of the cell. I'd like this panel's height to be animated together with cell itself.
I've tried 2 ways:
First: Changing row height and setting constraints as on the picture above:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.beginUpdates()
tableView.endUpdates()
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let selectedIndexPath = tableView.indexPathForSelectedRow
return indexPath == selectedIndexPath ? 120.0 : 70.0
}
Second: Setting row's height to UITableViewAutomaticDimension
, adding height constraint to the blue area and changing this constraint if user taps on cell.
Link to the repo
Both ways change blue region heigh instantly and then animate cell height. I need blue region to animate smoothly together with cell heigh, so white spacing between cells is unchanged.