证明UICollectionView的最后一行 [英] Justify last line of UICollectionView
问题描述
据我所见, UICollectionViewFlowLayout
证明除了最后一行之外的所有部分的行。因此,例如,如果没有足够的项目来填充超过1行,则结果不合理。
As far as I can see, UICollectionViewFlowLayout
justifies all the lines of a section except the last one. So for example, if there aren't enough items to fill more than 1 line, the result is not justified.
配置或子类的最简单方法 UICollectionViewFlowLayout
这样它也可以证明一个部分的最后一行?
What is the simplest way to either configure or subclass UICollectionViewFlowLayout
so that it also justifies the last line of a section?
推荐答案
您可以通过继承UICollectionViewFlowLayout并覆盖<来执行此操作code> layoutAttributesForElementsInRect:和 layoutAttributesForItemAtIndexPath:
将所有项目放在最后一行(第一行除外,这已经是正确的)你想要它们,通过更改项目的UICollectionViewLayoutAttributes对象的 frame
属性。
You can do this by subclassing UICollectionViewFlowLayout and overriding layoutAttributesForElementsInRect:
and layoutAttributesForItemAtIndexPath:
to place all the items in the last line (except the first, which is already correct) where you want them, by changing the frame
property of the item's UICollectionViewLayoutAttributes object.
这篇关于证明UICollectionView的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!