I had a problem with creating unfolding cells. I'm use a UIStackView. The problem is that when the cell is minimized, the lower view rides over the top and it turns out an ugly animation.
here is my methods
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("tap")
self.tableView.beginUpdates()
let cell = tableView.cellForRow(at: indexPath) as! TableViewCell
cell.animate(duration: 0, c: {
cell.stufView.layoutIfNeeded()
})
self.tableView.endUpdates()
}
and cell method animate
func animate(duration:Double, c: @escaping () -> Void) {
UIView.animateKeyframes(withDuration: duration, delay: 0, options: .calculationModePaced, animations: {
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: duration, animations: {
self.stufView.isHidden = !self.stufView.isHidden
if self.stufView.alpha == 1 {
self.stufView.alpha = 0.5
} else {
self.stufView.alpha = 1
}
})
}, completion: { (finished: Bool) in
print("animation complete")
c()
})
}
my storyboard