【问题标题】:Swift Pinterest Layout add headerSwift Pinterest 布局添加标题
【发布时间】: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


    【解决方案1】:

    解决了。我确实设法更改了 PinterestLayout 库以在其中创建一个标题。如果人们需要解决方案,可能会更新答案。

    【讨论】:

    • 用户已经要求解决方案(遗憾的是,由于没有评论权限,他们在没有答案的答案中这样做了)。如果您有解决方案,请提供。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    相关资源
    最近更新 更多