我在垂直收集视图中做一个水平收集视图。它非常适合垂直收集视图。但是在水平的cv中,第一个单元格的左边有一些空间,就像图像一样。我已将水平收集的视图涂成黄色。UIEdgeInsetMake只适用于上、下和右,而不适用于左侧。即使我使用委托方法,insetForSectionAtIndex也会得到相同的结果。知道为什么不管用吗?

垂直cv的单元格中只包含一个集合视图。在第一个细胞里
- (void)layoutSubviews {
CGFloat itemHeight = [_innerCell intrinsicContentSize].height;
CGFloat itemWidth = (CGRectGetWidth([UIScreen mainScreen]).bounds));
_cvLayout = (id) _collectionView.collectionViewLayout;
_cvLayout.sectionInset = UIEdgeInsetMake(0,0,0,0);
_cvLayout.itemSize = CGSizeMake(itemWidth, itemHeight);
}发布于 2019-11-07 14:54:02
只要设置.contentInset属性的collectionView,它就能工作。
示例代码:
self.collectionView.contentInset = UIEdgeInsets.init(top: 0, left: 20, bottom: 0, right: 0)https://stackoverflow.com/questions/58750614
复制相似问题