-
-
Save edwardean/a2aac17dade2cdfd1cc9078976ae7bd6 to your computer and use it in GitHub Desktop.
Resize a collection view to its content with AutoLayout via http://stackoverflow.com/a/26232188
This file contains hidden or 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 DynamicCollectionView : UICollectionView | |
| @end | |
| @implementation DynamicCollectionView | |
| - (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