Created
March 3, 2016 10:56
-
-
Save nenadvulic/f978ec0f71bfc83c9918 to your computer and use it in GitHub Desktop.
UICollectionView snap cell vertically
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
- (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity { | |
CGPoint contentOffset = CGPointZero; | |
NSInteger itemHeight = 130; | |
NSInteger padding = 10; | |
NSInteger index = round(proposedContentOffset.y / (itemHeight + padding)); | |
NSInteger x = (itemHeight + padding) * index; | |
contentOffset = CGPointMake(proposedContentOffset.x, x); | |
return contentOffset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment