YJWaterFlowLayout 0.1.7

YJWaterFlowLayout 0.1.7

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2018年3月
SPM支持 SPM

Zyj163 维护。



  • Zyj163

YJWaterFlowLayout

CI Status Version License Platform

示例

要运行示例项目,请先克隆代码库,然后从 Example 目录中先运行 pod installimage

需求

安装

YJWaterFlowLayout 可以通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中

pod "YJWaterFlowLayout", :git => 'https://github.com/Zyj163/YJWaterFlowLayout.git'

使用

属性:

waterCount

瀑布流的条数,默认为2(优先级低于代理方法中设置)

minimumWaterSpacing

流间距,默认10(优先级低于代理方法中设置)

minimumItemSpacing

同一流中的item间距,默认10(优先级低于代理方法中设置)

headerSize

section头视图大小,默认无(优先级低于代理方法中设置)

footerSize

section脚视图大小,默认无(优先级低于代理方法中设置)

hasSectionBackground

是否包含section背景图,默认无(优先级低于代理方法的设置)

sectionInset

section内边距,默认无(优先级低于代理方法中设置)

layoutDirection

流动方向,默认纵向

unionSize

批量布局个数,可根据一屏最多可显示多少个item来设置,默认20

delegate 代理 moveAction 拖拽代理

流条数,可选实现,如果没有实现,使用属性waterCount,返回≤0当作未实现处理 unc collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: YJWaterFlowLayout, waterCountForSection section: Int) -> Int

是否含有background,可选实现 func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: YJWaterFlowLayout, hasBackgroundInSection section: Int) -> Bool

根据返回的size计算宽高比,必须实现

func collectionView (_ collectionView: UICollectionView,layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize

头视图/脚视图大小,可选实现 func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: YJWaterFlowLayout, sizeForHeaderForFooterInSection section: Int, elementKind: String) -> CGSize

返回section中内边距,可选实现,如果没有实现,使用属性sectionInset

func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: NSInteger) -> UIEdgeInsets

返回section中同一流中item的间距,可选实现,如果没有实现,使用属性minimumItemSpacing

func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumItemSpacingForSection section: NSInteger) -> CGFloat

返回section中流间距,可选实现,如果没有实现,使用属性minimumWaterSpacing

func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumWaterSpacingForSection section: NSInteger) -> CGFloat

流宽度,可选实现,如果没有实现根据contentInsets、minimumWaterSpacing、waterCount计算得来,返回≤0当作未实现处理 func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: YJWaterFlowLayout, waterWidthForSection section: Int, at index: Int) -> CGFloat

修改attributes,background/header/footer/item, kind为nil时为item,可选实现 func collectionView (_ collectionView: UICollectionView, layout collectionViewLayout: YJWaterFlowLayout, relocationForElement kind: String?, currentAttributes: UICollectionViewLayoutAttributes)

拖拽需要实现的方法 extension ViewController: YJWaterLayoutMovable { func enableMoveItem(_ layout: YJWaterFlowLayout) -> Bool { return true } } func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { (collectionView.collectionViewLayout as! YJWaterFlowLayout).moveItem(&datas, moveItemAt: sourceIndexPath, to: destinationIndexPath) }

YJCollectionSectionHeader header的类型string YJCollectionSectionFooter footer的类型string YJCollectionSectionBackground background的类型string 以上三种类型用来替换系统提供的UICollectionElementKindSectionHeader等,用法相同,具体可查看demo

YJCollectionAutoInt: Int = 0 YJCollectionAutoFloat: Float = 0 YJCollectionAutoCGFloat: CGFloat = 0 YJCollectionAutoSize: CGSize = CGSize.zero YJCollectionAutoInsets: UIEdgeInsets = UIEdgeInsets.zero

作者

Zyj163, [email protected]

许可证

YJWaterFlowLayout遵循MIT许可证。有关更多信息,请参阅LICENSE文件。