Skip to content

Latest commit

 

History

History
76 lines (61 loc) · 2 KB

README_CN.md

File metadata and controls

76 lines (61 loc) · 2 KB

中文介绍

功能

  • 设计优雅,使用方便
  • 可适用于各种各样的流式布局
  • 纯Swift项目

环境要求

  • iOS 8.0+
  • Xcode 8.3+
  • Swift 3.1+

安装

CocoaPods

Podfile配置如下:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'ZJFlexibleLayout'
end

Carthage

Cartfile配置如下:

github "zzjzz9266a/ZJFlexibleLayout"

运行 carthage update 之后把生成的ZJFlexibleLayout.framework 拖进项目。

如何使用

1、创建一个 ZJFlexibleLayout并添加代理,在创建UICollectionView的时候把layout传进去:

let layout = ZJFlexibleLayout(delegate: self)
layout.collectionHeaderView = headerView    //could be nil
collectionView = UICollectionView(frame: kScreenBounds, collectionViewLayout: layout)

2、实现协议ZJFlexibleDataSource,只需要实现前两个方法即可:

protocol ZJFlexibleLayoutDataSource: class{

    //控制对应section的瀑布流列数
    func numberOfCols(at section: Int) -> Int
    //控制每个cell的尺寸,实质上就是获取宽高比
    func sizeOfItemAtIndexPath(at indexPath : IndexPath) -> CGSize
    //控制瀑布流cell的间距
    func spaceOfCells(at section: Int) -> CGFloat
    //section 内边距
    func sectionInsets(at section: Int) -> UIEdgeInsets
    //每个section的header尺寸
    func sizeOfHeader(at section: Int) -> CGSize
    //每个cell的额外高度
    func heightOfAdditionalContent(at indexPath : IndexPath) -> CGFloat
}

Demo

开源协议

ZJFlexibleDataLayout 遵循 MIT 开源协议,具体查看LICENSE.