我正在实现自定义布局UICollectionview,但是我看到第一行与第二行的框架不同。我希望所有单元格都以其先前的单元格结束。
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .vertical //.horizontal
layout.itemSize = CGSize.init(width: UIScreen.main.bounds.size.width - 40, height: 38)
layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
layout.minimumInteritemSpacing = 10.0
self.collectionView.setCollectionViewLayout(layout, animated: true)
self.collectionView.translatesAutoresizingMaskIntoConstraints = false
self.collectionView.invalidateIntrinsicContentSize()
self.collectionView.setNeedsLayout()
self.collectionView.layoutIfNeeded()
layout.invalidateLayout()