[英]Collection View Dynamic Cell size in ios
如何通过收藏夹视图实现此目的? 我已经尝试过sizeForItemAtIndexPath,但是没有按我的意愿工作?
谁能建议我该怎么做?
编辑:我已经完成:
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.item==0)
{
return CGSizeMake(200,200);
}
else
{
return CGSizeMake(90,90);
}
并得到回应:
使用UICollectionViewDelegateFlowLayout方法指定每个单元格所需的大小。 该方法是:
Objc:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
迅速
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
}
定义所需的CGSize,单元格将采用您定义的宽度和高度。
您的UIViewController必须实现UICollectionViewDelegateFlowLayout协议
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.