-
-
Save pwblaine/ef4937fc1519cf060ac0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // | |
| // UIScrollView+Extensions.h | |
| // | |
| // | |
| @interface UIScrollView (Extensions) | |
| /// Returns true if the content has been scrolled all the way to the top (by pulling the content up). | |
| - (BOOL)isScrolledToTop; | |
| /// Returns true if the content has been scrolled all the way to the bottom (by pulling the content down). | |
| - (BOOL)isScrolledToBottom; | |
| @end |
This file contains hidden or 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
| // | |
| // UIScrollView+Extensions.m | |
| // | |
| // | |
| #import "UIScrollView+Extensions.h" | |
| @implementation UIScrollView (Extensions) | |
| - (BOOL)isScrolledToTop { | |
| return (self.contentOffset.y <= [self verticalOffsetToTop]); | |
| } | |
| - (BOOL)isScrolledToBottom { | |
| return (self.contentOffset.y >= [self verticalOffsetToBottom]); | |
| } | |
| #pragma mark - Utils | |
| - (CGFloat)verticalOffsetToTop { | |
| CGFloat verticalOffsetTop = self.contentInset.top; | |
| return -verticalOffsetTop; | |
| } | |
| - (CGFloat)verticalOffsetToBottom { | |
| CGFloat verticalOffsetBottom = (self.contentSize.height + self.contentInset.bottom - self.bounds.size.height); | |
| return verticalOffsetBottom; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment