Skip to content

Instantly share code, notes, and snippets.

@jtrivedi
Last active February 24, 2024 17:12
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtrivedi/c97c9718f2052beb3fd21bb18e854f08 to your computer and use it in GitHub Desktop.
Save jtrivedi/c97c9718f2052beb3fd21bb18e854f08 to your computer and use it in GitHub Desktop.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
for (i, view) in scrollView.subviews.enumerated() {
var ty = 0.0
if scrollView.contentOffset.y < 0 {
// We're scrolling past the top of the scroll view.
// Translate each item in the scroll view by some amount based on its index and scroll offset.
ty = CGFloat(i) * abs(offsetY) / 8.0 * pow(1.12, CGFloat(i))
}
view.transform = CGAffineTransform(translationX: 0, y: ty)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment