Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chiahsien committed Sep 5, 2017
2 parents 7186ee6 + 179fabd commit 95b703f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
12 changes: 9 additions & 3 deletions CHTCollectionViewWaterfallLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion CHTCollectionViewWaterfallLayout.podspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion Demo/Objective-C/Demo/CHTCollectionViewWaterfallCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Demo/Objective-C/Demo/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 95b703f

Please sign in to comment.