Specify row and column number for UICollectionView

前端 未结 5 1835
失恋的感觉
失恋的感觉 2021-01-03 23:25

I want to show a UICollectionView which contains exactly 2 rows and 100 cells in each row.

// 1
- (NSInteger)collectionView:(UICollectionView *)view numberOf         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 23:56

    For 3 cells per row .. Add this code.

    - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
    {
         return CGSizeMake(collectionView.frame.size.width/3.2 , 100);
    }
    

提交回复
热议问题