我在 uiTableViewCell 中添加了一个无限动画,它只是在表格 View 单元格内闪烁一个 UILabel。
我的问题是,当我滚动 tableview 时它只是停止闪烁
我的代码是
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("TripListCell", forIndexPath: indexPath) as! TripListCell
let trip = tripList[indexPath.section]
cell.lblTripDirection.textColor = UIColor(red: 51/255, green: 210/255, blue: 123/255, alpha: 1.0)
UIView.animateWithDuration(0.5, delay: 0.0, options: [.CurveEaseInOut, .Repeat, .Autoreverse, .AllowUserInteraction], animations: {
cell.lblTripDirection.alpha = 0.0
}, completion: {
bool in
cell.lblTripDirection.alpha = 1.0
cell.lblTripDirection.textColor = UIColor.blackColor()
})
return cell
}
更新:
UIView.commitAnimations() 在返回对我有用的单元格之前。 谢谢大家:)
最佳答案
这是因为 cellForRowAtIndexPath
重新使用同一个单元格来显示其他数据。所以你不应该在 cellForRowAtIndexPath
中编写你的动画。
你应该尝试在custom cell class
的awakeFromNib
中编写或者你应该使用willDisplayCell
方法来编写动画。
希望这会有所帮助:)
关于ios - 滚动 uitableviewcell 后 UIView.animateWithDuration 停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37316282/