gpt4 book ai didi

ios - Swift iOS 如何删除顶部填充 UICollectionView

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

override func viewDidLoad(){
super.viewDidLoad()
scrollView.collectionViewLayout = layout
scrollView.delegate = self
scrollView.dataSource = self
scrollView.contentInset = .zero
scrollView.scrollIndicatorInsets = .zero
scrollView.isDirectionalLockEnabled = true
scrollView.register(UINib(nibName: "RadioView", bundle: nil), forCellWithReuseIdentifier: "RadioViewController")
}
lazy var layout: UICollectionViewFlowLayout = {
let layout = UICollectionViewFlowLayout()
layout.minimumLineSpacing = 0
layout.headerReferenceSize = .zero
layout.sectionInset = .zero
layout.scrollDirection = UICollectionViewScrollDirection.horizontal
return layout
}()

背景颜色红色是 UICollectionView

backgorund Color Black 是 UICollectionViewCell

enter image description here

我想将单元格移到左上角

enter image description here enter image description here

最佳答案

如果不是布局约束问题,那么:

collectionView.contentInset = UIEdgeInsets.zero

也有可能你已经实现了:

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
//...
}

在这种情况下,您需要将方法返回值 top 属性设置为 0

关于ios - Swift iOS 如何删除顶部填充 UICollectionView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52946131/

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