如何减少 collectionviewcell 和集合视图之间的顶部 space
how to reduce the top space between collectionviewcell and collection view
我在我的项目中使用集合视图。
集合视图和集合视图单元格之间总是有一个填充。
我想在集合视图单元格与其集合视图容器之间设置 space。
我该怎么做?
查看 UICollectionViewDelegateFlowLayout:https://developer.apple.com/documentation/uikit/uicollectionviewdelegateflowlayout
您可以使用此方法告诉集合视图在 rows/columns:
之间您想要多少 space
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
确保您设置了 collectionView 委托。
我在我的项目中使用集合视图。
集合视图和集合视图单元格之间总是有一个填充。
我想在集合视图单元格与其集合视图容器之间设置 space。
我该怎么做?
查看 UICollectionViewDelegateFlowLayout:https://developer.apple.com/documentation/uikit/uicollectionviewdelegateflowlayout
您可以使用此方法告诉集合视图在 rows/columns:
之间您想要多少 spacefunc collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
确保您设置了 collectionView 委托。