调整 UICollectionViewCell 以适应内容 [英] Adjust UICollectionViewCell to fit content
本文介绍了调整 UICollectionViewCell 以适应内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个标签,设置为根据其内容调整大小.我希望 UICollectionViewCell 也这样做.我无论如何都找不到实现它.
I have a label that is set to resize to its content. I want the UICollectionViewCell to do the same. I cannot find anyway to implement that.
可以在下面找到描述我当前安排的图片:
A picture describing my current arrangement can be found below:
推荐答案
我想你会想要实现 UICollectionViewDelegateFlowLayout 方法 collectionView:layout:sizeForItemAtIndexPath: 根据内容调整每个集合项的大小.
I think you'll want to implement the UICollectionViewDelegateFlowLayout method collectionView:layout:sizeForItemAtIndexPath: to adjust the size of each collection item based on the contents.
这是一个关于集合视图的教程,涵盖了这个特定主题.
这篇关于调整 UICollectionViewCell 以适应内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文