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

标签 swift animation uicollectionviewcell catransform3d

<分区>

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

    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)") 
}

关于swift - 不可点击的单元格,wen 动画打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56084950/

相关文章:

arrays - 数组转换问题

ios - 如何设置动态 UICollectionView 单元格高度?

swift - `func<T: Type>` 和 `func<T>(..) where T: Type` 之间的区别?

iOS - 如何使用 Swift 在 UITableview 中以矩阵格式(行和列)显示值

ios - CSS 动画变换 : translate poor performance on iPad

android - android 的 Canvas 滚动背景

java - Android如何开始系列动画

uicollectionview - 如果在 iOS8 Today Extension 中按下 uicollectionviewcell 的透明部分,则没有任何反应

swift - 更改 UICollectionViewCell 内项目的大小

ios - iOS/Swift 中函数旁边的 "M"是什么意思?