UICollectionView
いくつかのセルを含む があります。
各セルはそのUILabel
中に 1 つを保持します。ラベル内には 1 文字があり、タイルとして機能します (それ自体)。さらにセルが追加された場合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
ですか?