Created
February 11, 2013 05:40
-
-
Save jessedc/4752902 to your computer and use it in GitHub Desktop.
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
- (void)scrollViewDidZoom:(UIScrollView *)scrollView | |
{ | |
[self updateZoomableViewCenter:scrollView]; | |
} | |
- (void)updateZoomableViewCenter:(UIScrollView *)scrollView | |
{ | |
CGSize scrollViewSize = scrollView.bounds.size; | |
CGSize contentSize = scrollView.contentSize; | |
CGFloat offsetX = (scrollViewSize.width > contentSize.width) ? (scrollViewSize.width - contentSize.width) / 2.f : 0.f; | |
CGFloat offsetY = (scrollViewSize.height > contentSize.height) ? (scrollViewSize.height - contentSize.height) / 2.f : 0.f; | |
UIView *zoomableView = [scrollView.delegate viewForZoomingInScrollView:scrollView]; | |
zoomableView.center = CGPointMake(contentSize.width / 2.f + offsetX, contentSize.height / 2.f + offsetY); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment