title: Create Quilt Layouts in UICollectionView
body: <p><img src="https://i.stack.imgur.com/QI2ol.png" alt="enter image description here"></p>
  
  <p>I need this type of UICuollectionView.Each cell have one image and a label.The cell height and width depends on text of that label.</p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:          (NSIndexPath *)indexPath {
  
     CollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"kCellID"  forIndexPath:indexPath];
  if(cell == nil){
      cell = [[[NSBundle mainBundle] loadNibNamed:@"CollectionViewCell" owner:self options:nil] lastObject];
  }
  cell.backgroundColor = [UIColor redColor];
  cell.image.image = [UIImage imageNamed:[self.arrPhotos objectAtIndex:indexPath.row]];
  [cell.image setFrame:CGRectMake(cell.image.frame.origin.x, cell.image.frame.origin.y, cell.image.frame.size.width,100)];
  float f = [self getHeightCalculateForTheText:[arrText objectAtIndex:indexPath.row]  andwidth:96];
  [cell.label setFrame:CGRectMake(0,100,96, f)];
  cell.label.text = [arrText objectAtIndex:indexPath.row];
  [cell setFrame:CGRectMake(cell.frame.origin.x, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.width+f-20+10)];
  return cell;
  }
  
  - (CGSize) blockSizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  if(indexPath.row &gt;= self.arrPhotos.count)
      NSLog(@"Asking for index paths of non-existant cells!! %d from %d cells", indexPath.row, self.arrPhotos.count);
  float f = [self getHeightCalculateForTheText:[arrText objectAtIndex:indexPath.row]  andwidth:96];
  
  if (f &gt; 0 &amp;&amp; f&lt; 30)
      return CGSizeMake(1, 2);
  else if (f &gt; 30 &amp;&amp; f&lt; 60)
      return CGSizeMake(1, 3);
  else if (f &gt; 60 &amp;&amp; f&lt; 90)
      return CGSizeMake(1, 4);
  else if (f &gt; 90 &amp;&amp; f&lt; 120)
      return CGSizeMake(1, 5);
  else if (f &gt; 120 &amp;&amp; f&lt; 150)
      return CGSizeMake(1, 6);
  else if(f &gt; 150 &amp;&amp; f&lt; 180)
      return CGSizeMake(1, 7);
  
  return CGSizeMake(1,1);
  }
  </code></pre>
  
  <p>But my cells getting squeezed.<img src="https://i.stack.imgur.com/jXOlv.png" alt="enter image description here"></p>
  
  <p>can you get me know what's the problem is?</p>