mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
collectionview cell sizes are now not calculated upfront 😭
need to fix why theyre not expanding horizontally and that theyre too big
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -104,10 +104,11 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
|
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes {
|
||||||
super.preferredLayoutAttributesFitting(layoutAttributes)
|
let layoutAttributes = super.preferredLayoutAttributesFitting(layoutAttributes)
|
||||||
guard label.text != nil else { return layoutAttributes }
|
guard label.text != nil else { return layoutAttributes }
|
||||||
let labelHeight = label.sizeThatFits(CGSize(width: self.contentView.frame.width, height: .infinity)).height
|
let labelHeight = label.sizeThatFits(CGSize(width: layoutAttributes.size.width, height: .infinity)).height
|
||||||
layoutAttributes.size = CGSize(width: self.contentView.frame.width, height: labelHeight+4+view.frame.height)
|
layoutAttributes.size = CGSize(width: layoutAttributes.size.width, height: labelHeight+4+view.frame.height)
|
||||||
|
print(label.text!, layoutAttributes.size)
|
||||||
return layoutAttributes
|
return layoutAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell {
|
|||||||
}
|
}
|
||||||
let totalSpacing = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0 * (cols-1)
|
let totalSpacing = (collectionView.collectionViewLayout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 0 * (cols-1)
|
||||||
let itemWidth = (availWidth-totalSpacing)/cols
|
let itemWidth = (availWidth-totalSpacing)/cols
|
||||||
layoutAttributes.size = CGSize(width: itemWidth, height: layoutAttributes.size.height)
|
layoutAttributes.size = CGSize(width: itemWidth, height: itemWidth)
|
||||||
|
print(layoutAttributes.size)
|
||||||
return layoutAttributes
|
return layoutAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||