swiftanimationuicollectionviewcellcatransform3d

non clickable cell, wen animation is on


I use simple animation in my project

    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
    }

The problem is that when I quickly scroll down the page (my UiCollectionView has many cells) and try to stop scrolling somewhere in the middle, it does not work for me because the animation of the appearance of the cells still lasts. it turns out that while the animation does not end - they are not clickable

Is there any trick or feature so that the cells, when playing their animation, are clickable?


Solution

  • You can add allowUserInteraction to options

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