Last active
August 29, 2015 14:07
-
-
Save james-b-kelly/6d1494828f5f1a6fd072 to your computer and use it in GitHub Desktop.
UICollectionViewFlowLayout
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
//In UICollectionViewCell subclass implementation | |
- (UICollectionViewLayoutAttributes *)preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes { | |
layoutAttributes.size = CGSizeMake(layoutAttributes.frame.size.width, layoutAttributes.frame.size.height); | |
return layoutAttributes; | |
} | |
//In your view controller (containing the UICollectionView). | |
//In @interface | |
@property (nonatomic, strong) UICollectionViewFlowLayout *layout; | |
//In viewDidLoad | |
self.layout = [[UICollectionViewFlowLayout alloc] init]; | |
[self.collectionView setCollectionViewLayout:self.layout]; | |
//In viewWillAppear | |
self.layout.estimatedItemSize = CGSizeMake(160.0, 44.0); //E.g. for half-width cells. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment