根据标签大小更改 UICollectionView 单元格大小 [英] Change UICollectionView cell size depending on label size
问题描述
如何更改 UICollectionView 单元格高度?
How can I change the UICollectionView cell height?
如您所见,文本只是以..."结尾.当标签变大时,我希望尺寸变大,我希望单元格大小低于标签.我怎样才能做到这一点?希望你明白我的问题..有人请吗?
As you can see, the text just stops with "...". I want the size to get bigger when the label I bigger, I want the cell size to go below the label. How can I do this? Hope you understand my question.. Anyone please?
推荐答案
此答案根本不会改变单元格大小,但它可能是您问题的解决方案.在您设置单元格后的 cellForItemAtIndexPath
中:let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as!集合视图单元
This answer does not change the cell size at all, but it could be a solution to your problem. In your cellForItemAtIndexPath
after you set your cell: let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! CollectionViewCell
尝试添加:cell.imageText.adjustsFontSizeToFitWidth = true
这将使字体适合标签大小,文本越多,字体大小越小.让我知道这对您有何帮助.
This will make the font fit the label size, and the more text the smaller font size. Let me know how this worked for you.
这篇关于根据标签大小更改 UICollectionView 单元格大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!