我正在使用 UICollectionViewFlowLayout 来显示 GridView ,这就是我所看到的。
问题出在左侧的缝隙上。我对使用 UICollectionViewFlowLayout 有点陌生,所以我不知道如何消除那里的差距。
请帮忙
最佳答案
要减少左侧的空间,您可以在 UICollectionViewFlowLayout
上设置 sectionInset
属性
flowLayout.sectionInsets = UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
或者你可以实现这个方法:
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 50.0, left: 0.0, bottom: 50.0, right: 0.0)
}
If the delegate object does not implement the collectionView:layout:insetForSectionAtIndex: method, the flow layout uses the value in this property to set the margins for each section.
关于ios - UICollectionViewFlowLayout 左侧的间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35459331/