I have the below code which successfully causes a cell in a collectionView
to depress when tapped.
The issue is that one must hold for pretty long before the depression happens. Don't get me wrong. It's only about 1 second, but if you were to compare that speed to the speed of snapchat you can clearly see snapchat's is almost instant.
func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
UIView.animate(withDuration: 0.1, animations: {
collectionView.cellForItem(at: indexPath)!.transform = CGAffineTransform.identity.scaledBy(x: 0.95, y: 0.95)
})
}
Question: How could I make this animation for each cell, be instant or closer to it, like snapchat?
Update:
This seems to be doing it:
func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
UIView.animate(withDuration: 0.1, animations: {
collectionView.cellForItem(at: indexPath)!.transform = CGAffineTransform.identity.scaledBy(x: 0.95, y: 0.95)
}) { (true) in
UIView.animate(withDuration: 0.1, animations: {
collectionView.cellForItem(at: indexPath)!.transform = CGAffineTransform.identity.scaledBy(x: 1, y: 1)
})
}
}
This is an option if anyone wants something basic.