Last active
November 7, 2017 11:46
-
-
Save mukyasa/263732c4e482f591930e8805790b85f9 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
| public extension UIScrollView { | |
| var isAtTop: Bool { | |
| return contentOffset.y <= verticalOffsetForTop | |
| } | |
| var isAtBottom: Bool { | |
| return contentOffset.y >= verticalOffsetForBottom | |
| } | |
| var verticalOffsetForTop: CGFloat { | |
| let topInset = contentInset.top | |
| return -topInset | |
| } | |
| var verticalOffsetForBottom: CGFloat { | |
| let scrollViewHeight = bounds.height | |
| let scrollContentSizeHeight = contentSize.height | |
| let bottomInset = contentInset.bottom | |
| let scrollViewBottomOffset = scrollContentSizeHeight + bottomInset - scrollViewHeight | |
| return scrollViewBottomOffset | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment