【发布时间】:2017-06-25 14:45:33
【问题描述】:
我想在didSelectItem 上为collectionViewCell 提供新闻效果。单击时,我想添加一些颜色,经过一些延迟后,我想恢复颜色。在尝试下面的代码时,只有在延迟一段时间后才会添加按下效果。谁能建议如何实现这一目标?
DispatchQueue.global(qos: .utility).async {
let cell = collectionView.cellForItem(at: indexPath) as ..cell
// Change bg color for foreground layer
DispatchQueue.main.async {
Timer.scheduledTimer(timeInterval: 0.10, target: self, selector: #selector(self.updateCell(timer:)) , userInfo: ["cell":cell,"collectionview":collectionView], repeats: false)
}
// Some calculations
}
【问题讨论】:
-
您遇到的问题请提一下。
-
你击中的地方。
-
如果我不做任何操作,它会给出预期的结果。当我在计时器代码下方进行任何计算时,颜色变化仅在几个延迟后触发
标签: ios ipad swift3 uicollectionview uicollectionviewcell