【问题标题】:Resizable collectionview cells [closed]可调整大小的collectionview单元格[关闭]
【发布时间】:2018-12-15 18:53:04
【问题描述】:

我如何创建一个集合视图,什么会在单元格居中时调整它们的大小,就像上面图像中的一个?

【问题讨论】:

标签: ios swift user-interface user-experience


【解决方案1】:

您需要创建自定义UICollectionViewLayout,在其中计算单元格属性,具体取决于它们相对于集合视图中心的位置。之后,您覆盖布局的shouldInvalidateLayoutForBoundsChange(newBounds:) 方法:

override func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool {
  return true
}

此方法告诉您的集合视图,只要其边界发生变化(即发生滚动),它就应该使其布局无效。

您可能会发现 this tutorial 很有帮助,但您需要自己进行比例计算而不是旋转。

【讨论】:

    【解决方案2】:

    您可以使用 UICollectionView 自定义布局来实现。

    教程: https://www.raywenderlich.com/164608/uicollectionview-custom-layout-tutorial-pinterest-2

    或者你可以去 GitHub 上一个非常有名的库

    iCarousel: https://github.com/nicklockwood/iCarousel

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-12
      • 2019-09-29
      • 1970-01-01
      • 2020-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多