Dynamic size UICollectionView cell

后端 未结 4 1737
失恋的感觉
失恋的感觉 2020-12-01 00:20

\"enter

1) How can i achieve as shown in image with UICollectionView?

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 00:43

    Sorry this is super late... But maybe this will help people who haven't found an answer yet. If you have your images in an array, you can simply reference the image size and make the adjustments to the cell size from there:

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
    {
        UIImage *image = [imageArray objectAtIndex:indexPath.row];
    //You may want to create a divider to scale the size by the way..
        return CGSizeMake(image.size.width, image.size.height); 
    }
    

    Hope this helps..

提交回复
热议问题