Created
April 10, 2021 13:29
-
-
Save IsaAliev/031922126fc14a0494c70d4ff317452b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestCell: UICollectionViewCell, BoundingWidthAdoptable { | |
private var boundingWidth: CGFloat = 0 | |
func adoptBoundingWidth(_ width: CGFloat) { | |
boundingWidth = width | |
} | |
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { | |
let attributes = super.preferredLayoutAttributesFitting(layoutAttributes) | |
attributes.size = .init(width: boundingWidth, height: 100) | |
return attributes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment