UICollectionview中的水平和垂直分隔线。

问题描述 投票:0回答:1

我想在集合视图单元格之间用特定颜色(灰色)做分隔线,而不改变集合视图的BG颜色。在这里输入图片描述

ios swift xcode uicollectionview uicollectionviewlayout
1个回答
0
投票

你可以在CollectionViewCell里面使用UIView,宽度为1px或2px。


0
投票

将superview的背景色改为灰色,并在viewDidLoad生命周期方法中使用下面的代码将边缘昆虫添加到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 
© www.soinside.com 2019 - 2024. All rights reserved.