Skip to content

Instantly share code, notes, and snippets.

@junpluse
Last active October 9, 2015 02:28
Show Gist options
  • Save junpluse/3424216 to your computer and use it in GitHub Desktop.
Save junpluse/3424216 to your computer and use it in GitHub Desktop.
How to optimize content inset of UIScrollView when zoom out.
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
UIEdgeInsets inset = self.originalInset;
if (scrollView.zoomScale < 1) {
inset.top += scrollView.bounds.size.height - scrollView.contentSize.height;
inset.left += scrollView.bounds.size.width - scrollView.contentSize.width;
inset.bottom += scrollView.bounds.size.height - scrollView.contentSize.height;
inset.right += scrollView.bounds.size.width - scrollView.contentSize.width;
}
scrollView.contentInset = inset;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment