Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sourleangchhean168/d4d366dca52ff4932dd8becf36271eea to your computer and use it in GitHub Desktop.
Save sourleangchhean168/d4d366dca52ff4932dd8becf36271eea to your computer and use it in GitHub Desktop.
CollectionView Cell Animation in Swift 4
let cell = collectionView.cellForItem(at: indexPath)
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 5, options: [],
animations: {
cell!.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
},
completion: { finished in
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 5, options: .curveEaseInOut,
animations: {
cell!.transform = CGAffineTransform(scaleX: 1, y: 1)
},
completion: nil
)
}
)
//Ref: https://codepad.co/snippet/vE7tduOt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment