【发布时间】:2013-08-15 15:52:45
【问题描述】:
我有一个UICollectionView,其中包含一些单元格。
每个单元格中都包含一个UILabel。标签内有一个字母,它充当瓷砖(因此)。当更多单元格被添加到UICollectionView 时,UICollectionViewCells 会更改大小,如下所示:
-(CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
// NSLog(@"%s",__PRETTY_FUNCTION__);
NSLog(@"the word array count is: %i",self.wordArray.count);
if (self.wordArray.count <= 5) {
return CGSizeMake(50,50);
} else if (self.wordArray.count <= 6 ) {
return CGSizeMake(30, 30);
} else if (self.wordArray.count <= 8 ) {
return CGSizeMake(10, 10);
} else {
return CGSizeMake(100,100);
}
}
我现在要做的是在每次更改布局时重新调整单元格内的UILabel 大小。如何使用AutoLayout 使标签大小适合单元格大小?另外如何根据UILabel 大小更新字体大小?
【问题讨论】:
标签: ios ios6 uilabel uicollectionview autolayout