Skip to content

Instantly share code, notes, and snippets.

@jyliang
Created March 5, 2014 01:08
Show Gist options
  • Save jyliang/9359205 to your computer and use it in GitHub Desktop.
Save jyliang/9359205 to your computer and use it in GitHub Desktop.
ScrollView scroll to center point.
CGRect visibleRect = CGRectMake(0, 0, self.scrollView.contentSize.width, self.scrollView.contentSize.height);
CGRect centeredRect = CGRectMake(visibleRect.origin.x + visibleRect.size.width/2.0 - self.scrollView.frame.size.width/2.0,
visibleRect.origin.y + visibleRect.size.height/2.0 - self.scrollView.frame.size.height/2.0,
self.scrollView.frame.size.width,
self.scrollView.frame.size.height);
[self.scrollView scrollRectToVisible:centeredRect animated:NO];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment