Skip to content

RanYeee/StickCollectionView

Repository files navigation

StickCollectionView

实现collection层叠显示,类似wallet

效果如下

gif

#StickCollectionViewFlowLayout.m

- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
    
    NSArray *oldItems = [super layoutAttributesForElementsInRect:rect];
    NSMutableArray *allItems = [[NSMutableArray alloc]initWithArray:oldItems copyItems:YES];
    
    __block UICollectionViewLayoutAttributes *headerAttributes = nil;
    
    [allItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        UICollectionViewLayoutAttributes *attributes = obj;
        
        if ([attributes.representedElementKind isEqualToString:UICollectionElementKindSectionHeader]) {
            headerAttributes = attributes;
        }
        else {
            [self updateCellAttributes:attributes withSectionHeader:headerAttributes];
            
        }
    }];
    
    return allItems;
}

About

实现collection层叠显示,类似wallet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages