Giter Club home page Giter Club logo

collectionviewpageflowlayout's Introduction

CollectionViewPageFlowLayout

CollectionViewPageFlowLayout is a paged collection view flow layout in Swift

Usage

In any UICollectionViewController (or any UIViewController with a UICollectionView) create a CollectionViewPageFlowLayout instance and assign it to the collectionViewLayout property of the UICollectionView.

let pagedLayout = CollectionViewPageFlowLayout()
self.collectionView.collectionViewLayout = pagedLayout

That's it. Now you don't have to worry about the size changes of your collection view or the interface orientation of your view controller. The layout will always make sure it's paged.

A paged collection view

Page separators

Out of the box, the layout will make it look like your collection view's pages are stuck together. There are no margins between them. You can change this by setting the minimumLineSpacing property to a non-zero value. This will add spaces before and after the collection view items. Of course, you don't have to worry about the item size. The layout will take care of that for you. Just make sure you resize your collection view beyond it's superview so that the spaces are only visible while scrolling.

self.collectionView.frame = CGRectInset(self.view.bounds, -2, 0)
let pageLayout = self.collectionView.collectionViewLayout as CollectionViewPageFlowLayout
pageLayout.minimumLineSpacing = 4

A paged collection view with separator margins

collectionviewpageflowlayout's People

Contributors

sythn avatar

Stargazers

Husnain Ali avatar  avatar  avatar venj avatar Ratz avatar Fady H avatar  avatar  avatar Fabian Ehlert avatar Devran Cosmo Uenal avatar  avatar Konstantinos N. avatar Larry Mickie avatar Vito avatar tinytitan avatar Arton Ragsdale avatar Stamatis Sarlis avatar Sai Ram Kotha avatar Rocket avatar Paul Semionov avatar Elshad Yarmetov avatar Genady Okrain avatar Alessandro Orrù avatar Umit Kitapcigil avatar  avatar

Watchers

 avatar James Cloos 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.