Created
June 20, 2019 15:02
-
-
Save nekonora/8ee3d1c6609f396fcc2f16665791927f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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