gpt4 book ai didi

ios - Swift - 在 Collection View 的其余部分后面发送标题 View

转载 作者:行者123 更新时间:2023-11-28 10:03:25 25 4
gpt4 key购买 nike

好的,我有一个自定义贴纸应用程序,其中我试图实现这种效果,其余单元格后面的背景 View :

enter image description here

到目前为止,我已经创建了我的背景 View :

self.addSubview(bgView)
self.sendSubviewToBack(bgView)

尝试过

 func collectionView(_ collectionView: UICollectionView,
viewForSupplementaryElementOfKind kind: String,
at indexPath: IndexPath) -> UICollectionReusableView {

let headerView: HeaderCollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerCell", for: indexPath as IndexPath) as! HeaderCollectionReusableView

self.view.sendSubviewToBack(headerView)

但背景 View 仍然出现在单元格的顶部。我该怎么做?

最佳答案

有趣的效果!

你试过吗:

  • 添加虚拟标题 View
  • ... 在 Container View 后面
  • ... 包含一个 Collection View (具有透明背景)

例子:

Storyboard

storyboard

Result

result

Runtime

runtime

关于ios - Swift - 在 Collection View 的其余部分后面发送标题 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57298050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com