###简单的瀑布流布局
pod 'DYWaterflowLayout'
- Drag all source files under floder
DYWaterflowLayout
to your project.【将DYWaterflowLayout
文件夹中的所有源代码拽入项目中】 - Import the main header file:
#import "DYWaterflowLayout.h"
【导入主头文件:#import "DYWaterflowLayout.h"
】
##使用 #####创建布局
DYWaterflowLayout *layout = [[DYWaterflowLayout alloc] init];
layout.delegate = self;
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:layout];
#####实现代理
- (CGSize)waterflowLayout:(DYWaterflowLayout *)waterflowLayout heightForItemAtIndexPath:(NSIndexPath *)indexPath
{
//返回对应图片的大小
return [self.imageSizes[indexPath.item % 7] CGSizeValue];
}