UICollectionView with dynamic height not getting same space between cell

后端 未结 6 1786
野的像风
野的像风 2021-02-14 02:59

I am having similar problem like this

I am generating height of view at run time.Here is my code

@interface CollectionViewController ()
{
    NSMutableAr         


        
6条回答
  •  [愿得一人]
    2021-02-14 03:57

    Using following method

    //Swift

    func collectionView(_ collectionView: UICollectionView,
        layout collectionViewLayout: UICollectionViewLayout,
        sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize{
     return CGSizeMake(250, 150);
    }
    

    //Objective C

    -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(250, 150);
    }
    

提交回复
热议问题