diff --git a/CHTCollectionViewWaterfallLayout.m b/CHTCollectionViewWaterfallLayout.m index b207789..1a5bd12 100644 --- a/CHTCollectionViewWaterfallLayout.m +++ b/CHTCollectionViewWaterfallLayout.m @@ -428,7 +428,8 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { NSInteger i; NSInteger begin = 0, end = self.unionRects.count; NSMutableDictionary *cellAttrDict = [NSMutableDictionary dictionary]; - NSMutableDictionary *supplAttrDict = [NSMutableDictionary dictionary]; + NSMutableDictionary *supplHeaderAttrDict = [NSMutableDictionary dictionary]; + NSMutableDictionary *supplFooterAttrDict = [NSMutableDictionary dictionary]; NSMutableDictionary *decorAttrDict = [NSMutableDictionary dictionary]; for (i = 0; i < self.unionRects.count; i++) { @@ -448,7 +449,11 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { if (CGRectIntersectsRect(rect, attr.frame)) { switch (attr.representedElementCategory) { case UICollectionElementCategorySupplementaryView: - supplAttrDict[attr.indexPath] = attr; + if ([attr.representedElementKind isEqualToString:CHTCollectionElementKindSectionHeader]) { + supplHeaderAttrDict[attr.indexPath] = attr; + } else if ([attr.representedElementKind isEqualToString:CHTCollectionElementKindSectionFooter]) { + supplFooterAttrDict[attr.indexPath] = attr; + } break; case UICollectionElementCategoryDecorationView: decorAttrDict[attr.indexPath] = attr; @@ -460,7 +465,8 @@ - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { } } - NSArray *result = [cellAttrDict.allValues arrayByAddingObjectsFromArray:supplAttrDict.allValues]; + NSArray *result = [cellAttrDict.allValues arrayByAddingObjectsFromArray:supplHeaderAttrDict.allValues]; + result = [result arrayByAddingObjectsFromArray:supplFooterAttrDict.allValues]; result = [result arrayByAddingObjectsFromArray:decorAttrDict.allValues]; return result; } diff --git a/CHTCollectionViewWaterfallLayout.podspec b/CHTCollectionViewWaterfallLayout.podspec index 4260419..7dc3ec5 100644 --- a/CHTCollectionViewWaterfallLayout.podspec +++ b/CHTCollectionViewWaterfallLayout.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CHTCollectionViewWaterfallLayout" - s.version = "0.9.6" + s.version = "0.9.7" s.summary = "The waterfall (i.e., Pinterest-like) layout for UICollectionView." s.homepage = "https://github.com/chiahsien/CHTCollectionViewWaterfallLayout" s.screenshots = "https://raw.github.com/chiahsien/UICollectionViewWaterfallLayout/master/Screenshots/2-columns.png" diff --git a/Demo/Objective-C/Demo/CHTCollectionViewWaterfallCell.m b/Demo/Objective-C/Demo/CHTCollectionViewWaterfallCell.m index c53ff9d..7c18cee 100644 --- a/Demo/Objective-C/Demo/CHTCollectionViewWaterfallCell.m +++ b/Demo/Objective-C/Demo/CHTCollectionViewWaterfallCell.m @@ -15,7 +15,8 @@ - (UIImageView *)imageView { if (!_imageView) { _imageView = [[UIImageView alloc] initWithFrame:self.contentView.bounds]; _imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - _imageView.contentMode = UIViewContentModeScaleAspectFit; + _imageView.contentMode = UIViewContentModeScaleAspectFill; + [_imageView.layer setMasksToBounds:YES]; } return _imageView; } diff --git a/Demo/Objective-C/Demo/ViewController.m b/Demo/Objective-C/Demo/ViewController.m index 4ff41b9..6f87ea1 100644 --- a/Demo/Objective-C/Demo/ViewController.m +++ b/Demo/Objective-C/Demo/ViewController.m @@ -55,7 +55,7 @@ - (UICollectionView *)collectionView { - (NSArray *)cellSizes { if (!_cellSizes) { _cellSizes = @[ - [NSValue valueWithCGSize:CGSizeMake(400, 550)], + [NSValue valueWithCGSize:CGSizeMake(550, 550)], [NSValue valueWithCGSize:CGSizeMake(1000, 665)], [NSValue valueWithCGSize:CGSizeMake(1024, 689)], [NSValue valueWithCGSize:CGSizeMake(640, 427)]