Skip to content

Instantly share code, notes, and snippets.

@FlyingRadish
Created January 11, 2018 13:53
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 FlyingRadish/796d3ebd32403a4b23b2a568bd47e41e to your computer and use it in GitHub Desktop.
Save FlyingRadish/796d3ebd32403a4b23b2a568bd47e41e to your computer and use it in GitHub Desktop.
A UICollectionView which would wrap its content
@interface WrapCollectionView : UICollectionView
@end
@implementation WrapCollectionView
- (void) layoutSubviews
{
[super layoutSubviews];
if (!CGSizeEqualToSize(self.bounds.size, [self intrinsicContentSize]))
{
[self invalidateIntrinsicContentSize];
}
}
- (CGSize)intrinsicContentSize
{
CGSize intrinsicContentSize = self.contentSize;
return intrinsicContentSize;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment