【发布时间】:2020-06-10 09:49:05
【问题描述】:
我想在具有特定颜色(灰色)的集合视图单元格之间制作分隔线,而不更改集合视图的 BG 颜色。 enter image description here
【问题讨论】:
标签: ios swift xcode uicollectionview uicollectionviewlayout
我想在具有特定颜色(灰色)的集合视图单元格之间制作分隔线,而不更改集合视图的 BG 颜色。 enter image description here
【问题讨论】:
标签: ios swift xcode uicollectionview uicollectionviewlayout
你可以使用collectionViewCell里面的UIView,宽度1px或者2px
【讨论】:
在 viewDidLoad 生命周期方法中使用以下代码将 superview 的背景颜色更改为灰色并将边缘昆虫添加到 collectionView 中:-
private let spacing:CGFloat = 2.0
let layout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: spacing, left: spacing, bottom: spacing, right: spacing)
layout.minimumLineSpacing = spacing
layout.minimumInteritemSpacing = spacing
self.collectionView?.collectionViewLayout = layout
【讨论】: