我做了一些研究,但是我找不到任何关于如何在UICollectionView中水平居中单元格的代码示例.
而不是第一个单元格像这个X00,我希望它像这个0X0.有没有办法实现这个目标?
编辑:
想象我想要的东西:
当CollectionView中只有一个元素时,我需要它看起来像版本B. 当我有多个元素时,它应该像版本A但有更多元素.
当我只有1个元素时,它看起来像版本A,我想知道我怎么能让它看起来像B.
谢谢您的帮助!
I am currently using UICollectionView for the user interface grid, and it works fine. However, I'd like to be enable horizontal scrolling. The grid supports 8 items per page and when the total number of items are, say 4, this is how the items should be arranged with horizontal scroll direction enabled:
0 0 x x
0 0 x x
Run Code Online (Sandbox Code Playgroud)
Here 0 -> Collection Item and x -> Empty Cells
有没有办法使它们居中对齐,如:
x 0 0 x
x 0 0 x
Run Code Online (Sandbox Code Playgroud)
这样内容看起来更干净? …