Skip to content

Instantly share code, notes, and snippets.

@nekonora
Created June 20, 2019 15:02
Show Gist options
  • Save nekonora/8ee3d1c6609f396fcc2f16665791927f to your computer and use it in GitHub Desktop.
Save nekonora/8ee3d1c6609f396fcc2f16665791927f to your computer and use it in GitHub Desktop.
extension MyViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView == tableView { // Table view for example
var scrollY = scrollView.contentOffset.y + scrollView.contentInset.top + 40
if scrollY < 0 { scrollY = 0 }
constraintToChange.constant = -scrollY
if 0...10 ~= scrollY { viewToHide.alpha = 1 - (scrollY.rounded() / 10.0) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment