Latest0.1.7
Homepagehttps://github.com/Zyj163/YJWaterFlowLayout
LicenseMIT
Platformsios 8.0
FrameworksUIKit
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.
image

Requirements

Installation

YJWaterFlowLayout is available through CocoaPods. To install
it, simply add the following line to your Podfile:

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

Use

属性:

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

Author

Zyj163, [email protected]

License

YJWaterFlowLayout is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "YJWaterFlowLayout",
    "version": "0.1.7",
    "summary": "YJWaterFlowLayout",
    "description": "YJWaterFlowLayout  u6a2au5411u7eb5u5411u6d41u5e03u5c40uff0cu4e0du540csectionu53efu4ee5u6709u4e0du540cu5e03u5c40uff0cu652fu6301u7011u5e03u6d41uff0cu53efu62d6u62fditemuff0cu53efu6dfbu52a0u5934u89c6u56feu548cu811au89c6u56fe",
    "homepage": "https://github.com/Zyj163/YJWaterFlowLayout",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Zyj163": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Zyj163/YJWaterFlowLayout.git",
        "tag": "0.1.7"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "YJWaterFlowLayout/Classes/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This