不可点击的单元格,wen 动画打开

non clickable cell, wen animation is on

我在我的项目中使用了简单的动画

    let rotationTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 50, -40)
    cell.layer.transform = rotationTransform
    cell.alpha = 0.5
    UIView.animate(withDuration: 0.75) {
        cell.layer.transform = CATransform3DIdentity
        cell.alpha = 1.0
    }

问题是,当我快速向下滚动页面(我的 UiCollectionView 有很多单元格)并尝试在中间某处停止滚动时,它对我不起作用,因为单元格外观的动画仍然持续.事实证明,虽然动画没有结束 - 它们不可点击

有什么技巧或功能可以让单元格在播放动画时可以点击吗?

您可以将 allowUserInteraction 添加到选项

UIView.animate(withDuration: 0.75,delay:0.0,options:[.allowUserInteraction], animations: {
  cell.layer.transform = CATransform3DIdentity
  cell.alpha = 1.0
}) { (ok) in
    print("Ended \(ok)") 
}