Post

Replies

Boosts

Views

Activity

Reply to UICollectionViewCompositionalLayout incorrect item size
Implementing preferredLayoutAttributesFitting(_:) in my collection view cell fixed this problem: override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {     let targetSize = CGSize(width: layoutAttributes.frame.width, height: 0)     let modifiedAttributes = super.preferredLayoutAttributesFitting(layoutAttributes)     modifiedAttributes.frame.size = contentView.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)     return modifiedAttributes }
Jul ’21