Latest0.0.1
Homepagehttps://github.com/Loadar/CPFWaterfallFlowLayout
LicenseMIT
Platformsios 8.0, requires ARC
Authors

Swift瀑布流布局

使用方法

// 支持Pods
pod 'CPFWaterfallFlowLayout', '~>0.0.1'
// 引入对应模块
import CPFWaterfallFlowLayout

默认2列,暂不支持水平方向滑动

示例

// layout继承自UICollectionViewFlowLayout,属性配置相同
let layout = WaterfallLayout()
layout.minimumLineSpacing = 10
layout.minimumInteritemSpacing = 5
layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 20, right: 10)
layout.scrollDirection = .vertical

// 可指定全局列数
layout.columnCount = 3

// header粘附效果
layout.stickyHeaders = true
// 实现delegate方法可指定每个section列数
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, columnForSection section: Int) -> Int {
    return section + 2
}
// 随机size大小
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    if let size = sizeMap[indexPath] { return size }
    let size = CGSize(width: 100, height: random(in: 50..<200))
    sizeMap[indexPath] = size
    return size
}

Latest podspec

{
    "name": "CPFWaterfallFlowLayout",
    "version": "0.0.1",
    "summary": "Swiftu7011u5e03u6d41u5e03u5c40",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "chenpengfei": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Loadar/CPFWaterfallFlowLayout.git",
        "tag": "0.0.1"
    },
    "homepage": "https://github.com/Loadar/CPFWaterfallFlowLayout",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Classes/*.swift",
    "requires_arc": true
}

Pin It on Pinterest

Share This