Created
April 29, 2014 11:25
-
-
Save davidkatz/11397404 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
// calculate final required offset | |
int initialImageCenter = rectInTableView.origin.y + rectInTableView.size.height/2; | |
int screenWidth = [UIScreen mainScreen].bounds.size.width; | |
int currentDistanceFromCenter = screenWidth/2 - initialImageCenter; | |
int finalHorizontalOffset = currentDistanceFromCenter; | |
// calculate current offset based on drag position | |
int maxDragDistance = 100; // say we want the animation to complete while the finger drags up to 100 pixels | |
int currentDragRatio = currentDragDistance / maxDragDistance // assuming currentDragDistance is available | |
int currentHorizontalOffset = currentDragRatio*finalHorizontalOffset | |
[self.tableView setContentOffset:CGPointMake(0, currentHorizontalOffset]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment