【发布时间】:2016-02-23 15:57:57
【问题描述】:
我使用以下方法为表格视图的单元格设置动画:
func animateCells(tableView: UITableView) {
tableView.reloadData()
let cells = tableView.visibleCells
let tableHeight: CGFloat = tableView.bounds.size.height
for i in cells {
let cell: UITableViewCell = i as UITableViewCell
cell.transform = CGAffineTransformMakeTranslation(0, tableHeight)
}
var index = 0
for a in cells {
let cell: UITableViewCell = a as UITableViewCell
UIView.animateWithDuration(animationDuration, delay: animationDelay * Double(index),usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
cell.transform = CGAffineTransformMakeTranslation(0, 0);
}, completion: nil)
index += 1
}
}
这仅适用于表格视图中的单元格。但我也有一些带有标题的表格,在这些情况下动画不起作用。如何在上面的动画代码中包含标题?谢谢。
【问题讨论】:
-
我认为您必须使用
tableView.headerViewForSection()或tableView.tableHeaderView而不是visibleCells才能获得标题视图。
标签: ios swift uitableview