How to set collection view cell size in iOS?

Total Post:27


 1062  View(s)
Rate this:
I have created an Photo album using UICollectionView.
I want to handle cell size by codding.
If it is possible then please provide me the code.
Thank you.
  1. Re: How to set collection view cell size in iOS?

    To set the collection view cell size, you can use collectionView method sizeForItemAtIndexPath: .
    Here is an example:

    -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)layout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
      CGFloat width = (CGRectGetWidth(self.view.frame)/3.0f)-15);
      return CGSizeMake(width, (width *1.1f));
      // total 4 views displayed at a time;

    I hope the above code is helpful for you, because I am using that code in our own sample.

      Modified On Dec-29-2015 10:31:46 PM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.