I am trying to animate each cell of my UICollectionView
visibile in the frame.
Every time I scroll a new cell appears with the animation.
I am doing this using performBatchUpdates
inside cellForItemAtIndexPath
however, the animation is applied to all cells at the same time and its very fast. It seems that the animation of 1 second its not recognised.
Also I am trying to find the way to apply an animation to a cell when a button is pressed with no success.
The code I use is:
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let Cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! CellClass
self.collectionView?.performBatchUpdates({
Cell.layer.cornerRadius = 200
return
}){
completed in
UIView.animateWithDuration(1, animations: {
Cell.layer.cornerRadius = 0
})
}
Cell.playAnimationBtn.layer.setValue(indexPath.row, forKey: "indexPlayBtn")
}
@IBAction func actionGetAnimation(sender: UIButton)
{
let indexUser = (sender.layer.valueForKey("indexPlayBtn")) as! Int
//Cell selected do animation corners = 200
}