【发布时间】:2018-05-06 19:54:18
【问题描述】:
我将 collectionView 与库 PinterestLayout 一起使用。当我创建自己的UICollectionViewFlowLayout 时,我只需要添加.headerRefenceSize 和这两种方法:
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView`
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize
有了这个,我就有了我的标题。现在我将 PinterestLayout 继承从 UICollectionViewLayout 更改为 UICollectionViewFlowLayout 并在方法内部添加:prepare 以下行:
self.headerReferenceSize = CGSize(width: UIScreen.main.bounds.width, height: 75)
但仍然没有显示标题。谁能告诉我如何在PinterestLayout 中添加标题。
我需要保持PinterestLayout 为我的collectionView 提供的相同单元格图片比例。
【问题讨论】:
标签: swift uicollectionview uicollectionviewlayout pinterest