Skip to content

Instantly share code, notes, and snippets.

@darrarski
Created January 30, 2019 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrarski/7ff7aa658c817e6f0f4e14bbd6941567 to your computer and use it in GitHub Desktop.
Save darrarski/7ff7aa658c817e6f0f4e14bbd6941567 to your computer and use it in GitHub Desktop.
UIScrollView viewport frame getter
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