/CenteredFlowLayout

Centered Flow Layout for iOS

Primary LanguageSwiftMIT LicenseMIT

Centered Flow Layout for iOS

The CenteredFlowLayout class is a collection view layout which centers the elements in the collection view. To use it in Interface Builder all you have to do is to set your collection view layout to custom and choose CenteredFlowLayout as the class, right click Centered Flow Layout in the Document Outline pane on the left and assign your view controller as its delegate1, and lastly implement the CenteredFlowLayoutDelegate in your view controller which consists of a single method that returns the cell size at a given index path.

1: There's a known bug in Interface Builder where you cant assign the delegate to anything in this case. Then change the delegate of CenteredFlowLayout to AnyObject? and it should work.