Created
January 30, 2019 14:27
-
-
Save darrarski/7ff7aa658c817e6f0f4e14bbd6941567 to your computer and use it in GitHub Desktop.
UIScrollView viewport frame getter
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
import UIKit | |
extension UIScrollView { | |
var viewport: CGRect { | |
return CGRect( | |
origin: CGPoint( | |
x: contentOffset.x + adjustedContentInset.left, | |
y: contentOffset.y + adjustedContentInset.top | |
), | |
size: CGSize( | |
width: frame.width - adjustedContentInset.horizontal, | |
height: frame.height - adjustedContentInset.vertical | |
) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment