#import <UIKit/UIKit.h>
@interface albumHomeCollectionFlowLayout : UICollectionViewFlowLayout
@end
#import "albumHomeCollectionFlowLayout.h"
@implementation albumHomeCollectionFlowLayout
const NSInteger kMaxCellSpacing = 10;
//让item居左
//定义屏幕展示的范围和数量
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray* attributesToReturn = [super layoutAttributesForElementsInRect:rect];
NSArray * array = [[NSArray alloc] initWithArray:attributesToReturn copyItems:YES];
for (UICollectionViewLayoutAttributes* attributes in array) {
if (nil == attributes.representedElementKind) {
NSIndexPath* indexPath = attributes.indexPath;
attributes.frame = [self layoutAttributesForItemAtIndexPath:indexPath].frame;
}
}
return attributesToReturn;
}
//定义cell的布局
- (UICollectionViewLayoutAttributes *