【发布时间】:2019-08-30 08:03:07
【问题描述】:
我想在UITableView 单元格中使用动画扩展视图高度。
它正在工作,但动画无法按我的意愿工作。
我的代码是这样的。
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let cell = listingTableView.dequeueReusableCell(withIdentifier: "listingTableViewCell", for: indexPath) as! listingTableViewCell
//Charactristic expand
let isExpand = isExpandViewArr[indexPath.row]
if isExpand == true {
cell.expandBtn.setImage(UIImage(named: "down-arrow"), for: .normal)
UIView.animate(withDuration: 0.5) {
cell.expandViewHeight.constant = 0
self.loadViewIfNeeded()
}
}else{
cell.expandBtn.setImage(UIImage(named: "up-arrow"), for: .normal)
UIView.animate(withDuration: 0.5) {
cell.expandViewHeight.constant = 40
self.loadViewIfNeeded()
}
}
}
请查看链接上的屏幕:https://ibb.co/XjjXRz5
【问题讨论】:
-
你的意思是 它正在工作,但动画没有按我的意愿工作。 ?你期望的行为是什么,你得到了什么?
-
它正在扩展,但没有动画。我想用动画扩大高度。
-
@nico 打败了我。看看他的回答。
标签: ios swift iphone uitableview uianimation