Customization of Layout
– line spacing
– Inter cell spacing
– Scrolling direction
– Header Footer size
– Section inset
– Want single line -> play with insets
Supplementary views are data driven
Decoration views are layout driven -> independent from the data e.g: Background
Carries information from a Layout to a Collection view and gets supplied to all the views in the collection view. One instance per view. Attributes: center, size, frame, alpha, transform, zIndex (to indicate how cells are stacked on top of each other)
Layout that get information from the CollectionViewDelegate
– When a change is done in a layout, the layout gets invalidate via
– If you want to change a a property on the layout but you want it to be done with animation
performBatchUpdates:completion: to begin updates and end updates on a TableView (CollectionView). E.g: Item size on the layout
– CoverFlow we want to change transforms the view which means changing layout attributes, respond to method
shouldInvalidateForBoundsChange: Flowlayout implements this method on the rotation of the device
When implementing a CollectionView with custom Layout, think first if it can be solved by sublcassing
– Customise and add new kinds of views (decoration view, etc)
– Tweak layout attributes: To transform, alpha, etc.
– Add new layout attributes. Subclassing UICollectionViewLayoutAttributes to add additional layout attributes. E.g: to adjust some visual property on the cell to depend on the column.
– Gesture support, gesture to a specific cell.
– Custom insert and delete animations
Fully customizing UICollectionViewLayout
UICollectionViewLayout is an abstract class that needs to be extended in order to create a custom layout
tells the user scrollable area in the collection view, where the content is going to be layout
called to ask how to lay things out returns an array of LayoutAttributes
Additionally sometimes this is required as well.
Order of operation to call those methods
to do upfront calcs for layout e.g: circle layout, etc.
invalidateLayout (like in coverflow, when sizes need to change. Says to collection view to start over again)
– cycle continues