Created
December 2, 2014 22:55
-
-
Save eddiekaiger/24316e5e0481c898994e to your computer and use it in GitHub Desktop.
Scroll-Based Animation in iOS
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
- (void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
CGFloat scrollOffset = scrollView.contentOffset.y; | |
// Shift dismiss button up on scroll when user is at the top of the scrollview | |
if (scrollOffset < -[self tableViewOffsetTop]) { | |
self.dismissButton.transform = CGAffineTransformMakeTranslation(0, scrollOffset + [self tableViewOffsetTop]); | |
} | |
// Dismiss after user scrolls down far enough | |
CGFloat dismissThreshold = -([self tableViewOffsetTop] + 80); | |
if (scrollOffset < dismissThreshold) { | |
self.dismissButton.hidden = YES; | |
[self dismissHotlines]; | |
} | |
} | |
- (CGFloat)tableViewOffsetTop | |
{ | |
return [UIScreen screenHeight] / 4.0f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment