我想显示 3*3 集合视图动态高度单元格任何知道如何显示此内容的人
提前感谢.!!
以下是
您可以使用3 * 3 Collection View
有关iPhone屏幕尺寸的内容(假设您的收藏视图框架是根据屏幕尺寸设置的):
迅速
optional func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
var spaceBetweenCells = 12
var width = (self.collectionView.frame.size.width - spaceBetweenCells * 3) / 3
var height = (self.collectionView.frame.size.height - spaceBetweenCells * 3) / 3
return CGSizeMake(width, height)
}
目标C
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat spaceBetweenCells = 12;
CGFloat width = (self.collectionView.frame.size.width - spaceBetweenCells*3) / 3;
CGFloat height = (self.collectionView.frame.size.height - spaceBetweenCells*3) / 3;
return CGSizeMake(width, height);
}
希望这有帮助。