ios - UICollectionView 标题宽度

标签 ios uicollectionview uicollectionviewlayout uicollectionreusableview

在我的 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/

相关文章:

ios - Split View中的 Collection View Controller 不更新

ios - 为 UICollectionViewLayout 使用失效上下文

ios - 在启用 native 分页的情况下查看 UICollectionView 中的上一个/下一个单元格?

ios - 应用程序在第二点后卡住,Objective C

ios - UITableView 中的 TextField 退出FirstResponder

ios - UICollectionView 顶部单元格在动画键盘外观时消失

ios - 如何知道水平collectionView部分是否结束减速?

ios编程: Using threads to add multiple images to library

ios - 尝试找出从 Firestore 字典中删除元素的更好方法

ios - 带有自调整单元格的 UICollectionView 无法正确计算 contentSize