我有一个包含一些单元格的UICollectionView
每个单元格内都有一个UILabel
,标签内只有一个字母,并作为一个“瓷砖”(tile)呈现。当更多单元格被添加到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
的大小更新字体大小?
minimumScaleFactor
吗? - Eric