mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fix size calculations
This commit is contained in:
2 files changed
+2
-4
No files matched your search
@@ -108,7 +108,6 @@ class EmojiCollectionViewCell: PlainEmojiCollectionViewCell {
|
|||||||
guard label.text != nil else { return layoutAttributes }
|
guard label.text != nil else { return layoutAttributes }
|
||||||
let labelHeight = label.sizeThatFits(CGSize(width: layoutAttributes.size.width, height: .infinity)).height
|
let labelHeight = label.sizeThatFits(CGSize(width: layoutAttributes.size.width, height: .infinity)).height
|
||||||
layoutAttributes.size = CGSize(width: layoutAttributes.size.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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,10 +79,9 @@ class PlainEmojiCollectionViewCell: UICollectionViewCell {
|
|||||||
} else {
|
} else {
|
||||||
cols = max(1, floor(availWidth/width))
|
cols = max(1, floor(availWidth/width))
|
||||||
}
|
}
|
||||||
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: itemWidth)
|
layoutAttributes.size = CGSize(width: itemWidth.rounded(.down), height: itemWidth.rounded(.down))
|
||||||
print(layoutAttributes.size)
|
|
||||||
return layoutAttributes
|
return layoutAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||