Skip to content

Instantly share code, notes, and snippets.

@mitchellporter
Forked from ynechaev/gist:8123997
Last active August 29, 2015 14:21
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 mitchellporter/313dab93a6d1f98ae0e9 to your computer and use it in GitHub Desktop.
Save mitchellporter/313dab93a6d1f98ae0e9 to your computer and use it in GitHub Desktop.
@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UIImageOrientation scrollOrientation;
CGPoint lastPos;
}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.isDragging) {
UIView *myView = cell.contentView;
CALayer *layer = myView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000;
if (scrollOrientation == UIImageOrientationDown) {
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI*0.5, 1.0f, 0.0f, 0.0f);
} else {
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, -M_PI*0.5, 1.0f, 0.0f, 0.0f);
}
layer.transform = rotationAndPerspectiveTransform;
[UIView animateWithDuration:.5 animations:^{
layer.transform = CATransform3DIdentity;
}];
}
}
- (void) scrollViewDidScroll:(UIScrollView *)scrollView {
scrollOrientation = scrollView.contentOffset.y > lastPos.y?UIImageOrientationDown:UIImageOrientationUp;
lastPos = scrollView.contentOffset;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment