在我的 UICollectionViewFlowLayout 子类中我有这个:
self.headerReferenceSize = CGSizeMake(280, 44);
但是标题显示的宽度为 320,这是 Collection View 的宽度。根据文档,这是正确的:
During layout, only the size that corresponds to the appropriate scrolling direction is used. For example, for the vertical scrolling direction, the layout object uses the height value returned by your method. (In that instance, the width of the header would be set to the width of the collection view.)
但是,我需要宽度为 280,而不是拉伸(stretch)到 Collection View 的整个宽度。我该如何覆盖它?
最佳答案
您可以在标题上添加另一个自定义 View 并根据需要调整其大小。当然,您在标题上的所有组件都将覆盖您创建的自定义 View ...
关于ios - UICollectionView 标题宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23276993/