Fixes incorrect cell height for some News items

We need to take layoutMargins into account when calculating the height of the prototype cell.
This commit is contained in:
Riley Testut
2023-04-04 13:29:48 -05:00
parent adaf7a2560
commit 79210e94d2

View File

@@ -453,6 +453,10 @@ extension NewsViewController: UICollectionViewDelegateFlowLayout
return previousSize
}
// Take layout margins into account.
self.prototypeCell.layoutMargins.left = self.view.layoutMargins.left
self.prototypeCell.layoutMargins.right = self.view.layoutMargins.right
let widthConstraint = self.prototypeCell.contentView.widthAnchor.constraint(equalToConstant: collectionView.bounds.width)
NSLayoutConstraint.activate([widthConstraint])
defer { NSLayoutConstraint.deactivate([widthConstraint]) }