问题描述
我有一个集合视图,它基本上是一个水平表格视图.这是一行左右滚动的单元格.有点像没有花哨动画的旋转木马.我希望能够控制细胞之间的距离.在界面构建中有一个属性可以做到这一点.它在集合视图流布局中,在检查器中(在带有小标尺的选项卡中,您通常会看到约束).它被称为 Min.Spacing
有两种变体:For Cells
和 For Lines
.我更改了 For Cells
的值,但它不影响间距.更改参数 minimumInteritemSpacing
或使用集合视图回调都不会在每个部分的基础上指定该参数.帮助!
I have a collection view which is basically a horizontal table view. It's one line of cells that scrolls left and right. Sort of like a carousel without the fancy animation. I would like to be able to control the distance between cells. There is a property for doing that in the interface builde. It is in the collection view flow layout, in the inspector (in the tab with the little ruler where you usually see constraints). It is called Min. Spacing
and has two variants: For Cells
and For Lines
. I changed the value of For Cells
but it doesn't affect the spacing. Neither does changing the parameter minimumInteritemSpacing
or using the collection view callback for specifying that parameter on a per section basis. Help!
推荐答案
答案是在水平滚动的集合视图中,单元格之间的距离,甚至是水平距离,似乎都被For Lines 参数(在 IB 中)或
minimumLineSpacing
参数.
The answer is that in a horizontal scroll collection view, the distance between cells, even the horizontal distance, seems to be controlled by the For Lines
parameter (in IB) or minimumLineSpacing
parameter of the CollectionViewFlowLayout.
这个答案也隐藏在一些答案中我看到了关于集合视图中单元格间距的更普遍的问题:https://stackoverflow.com/a/48791318/826946 和https://stackoverflow.com/a/37420529/826946
This answer is also buried in some answers I saw more general question about cell spacing in collection views:https://stackoverflow.com/a/48791318/826946 andhttps://stackoverflow.com/a/37420529/826946
我决定把它分成一个单独的问题,直接解决水平滚动集合视图的问题.
I decided to separate it out into a separate question that directly addresses the issue of horitzontal scroll collection views.
这篇关于如何更改水平滚动集合视图中单元格之间的水平间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!