Created
August 28, 2014 18:16
-
-
Save ajayjapan/5e7ba49e51f1ca24b76d to your computer and use it in GitHub Desktop.
Adjust content size of collection view when flexible iOS 8 simulator size changes
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
@interface UICollectionViewFlowLayout (InvalidateOnBoundsChange) | |
@end | |
@implementation UICollectionViewFlowLayout (InvalidateOnBoundsChange) | |
- (UICollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange:(CGRect)newBounds { | |
UICollectionViewLayoutInvalidationContext *context = [super invalidationContextForBoundsChange:newBounds]; | |
CGRect oldBounds = self.collectionView.bounds; | |
CGFloat widthAdjustment = newBounds.size.width - oldBounds.size.width; | |
CGFloat heightAdjustment = newBounds.size.height - oldBounds.size.height; | |
context.contentSizeAdjustment = CGSizeMake(widthAdjustment, heightAdjustment); | |
return context; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment