【发布时间】:2016-07-24 11:33:29
【问题描述】:
我目前有一个 UITableView,其中一行返回 0.0,然后在用户点击“显示更多”按钮时展开。发生这种情况时,上面的行会根据容器的高度返回一个特定的值,这会立即发生。我想做的是在扩展/减少的同时创建某种动画。
这是我目前的代码:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if indexPath.row == 2 && self.numberOfElements >= 2 {
if detailsVisible == false {
self.showMoreLabel.text = "Show more (\(self.numberOfElements - 1))"
return 0.0
}
else {
self.showMoreLabel.text = "Show less"
return embedKonteringHeight
}
}
}
如果显示可扩展内容,var detailsVisible返回布尔值。
有没有一种简单的动画方法?我在想像一个简单的计数器增加/减少,它由 heightForRowAtIndexPath 在间隔内返回。
【问题讨论】:
标签: swift xcode uitableview jquery-animate heightforrowatindexpath