Code Monkey home page Code Monkey logo

autopagingflowlayout's Introduction

AutoPagingFlowLayout

根据collectionView datasource自动分页的,展示item的布局实现。废话不多说,请直接看图~~ image

系统要求

  • iOS 8.0
  • ARC
  • Swift 4.0

安装方法

支持CocoaPods 安装,pod search AutoPagingFlowLayout

也可以下载文件,拖放至项目目录

使用方法:

1.创建flowlayout configurator对象 并配置参数

        let configurator = WKAutomaticPagingFlowLayoutConfigurator()
        configurator.columnCountOfRow = 3 // 每行有3列
        configurator.rowCountOfPage = 2   // 每页展示2行
        configurator.contentInsets = UIEdgeInsetsMake(10, 10, 10, 10) //边距
        configurator.scrollDirection = .Horizontal
        configurator.columnSpacing = 5   // 行间距
        configurator.lineSpacing = 5 	 // 列间距

2.根据layout创建CollectionView

	let layout = WKAutomaticPagingFlowLayout(layoutConfigurator: configurator)
        let collectionView = UICollectionView(frame: CGRectZero, collectionViewLayout:layout)
        collectionView.pagingEnabled = true //自行指定分页属性 根据需要
        collectionView.wk_Size = CGSizeMake(
            CGFloat(self.matrix.columnCount) * 100, CGFloat(self.matrix.rowCount) * 100)

3.其他的步骤与正常使用UICollectionView一致

此布局会根据datasource 自动分页 并根据相关配置参数分配每个Item.

autopagingflowlayout's People

Contributors

hoowang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.