参考网络教程,自己总结而来
1. Core Layout Process(核心布局的处理过程)
继承UICollectionViewLayout必须实现如下方法:
- prepareLayout():
布局将要生效在方法里面计算好item的position,collection的size
- collectionViewContentSize()
返回CollectionViewContentSize 不是size(width,height),contentSize一般比size要大
- layoutAttributeForElementsInRect()
返回特定区域内的布局属性
2. Calculating Layout Attributes(计算 布局的属性)
cell 宽度不变,变高度 ,高度(caption,comment,image.size.height)
- 基本概念: UICollectionView
- UICollectionCell
- Supplementary Views
- Decoration Views(using custom layout)
Layouts can be swapped out during runtime and the collection view can even automatically animate switching from one layout to another!
- UICollectionViewDelegateFlowLayout
- sizeForItemAtIndexPath -> CGSize
- insetForSectionAtIndex -> UIEdgeInsets
- minimumLineSpacingForSectionAtIndex ->CGFloat
- minimumInteritemSpacingForSectionAtIndex ->CGFloat
- referenceSizeForHeaderInSection ->CGSize
- referenceSizeForFooterInSection ->CGSize