title: UICollectionView space between cells
body: <p>In my case I want completely remove any spaces between <code>UICollectionViewCell</code>'s. In iPhone 5 it works correct but iPhone 6 and up. Every time I scroll or in the initial load <code>UICollectionView</code> adds empty space for different rows. I know that could be difference in float values. For example 8.88888881 and 8.88888881.</p>
  
  <p>Green Line is empty space (<code>collection view</code> background color)</p>
  
  <p><a href="https://i.stack.imgur.com/cgDTc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cgDTc.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/zQASN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zQASN.png" alt="enter image description here"></a></p>
  
  <p>Every time I scroll this line change position.</p>
  
  <p>My code:</p>
  
  <pre><code>- (CGSize)collectionView:(UICollectionView *)collectionView
                    layout:(UICollectionViewLayout *)collectionViewLayout
    sizeForItemAtIndexPath:(nonnull NSIndexPath *)indexPath
  {
      CGFloat widthAndHeight = [self widthAndHeightForActiveCollectionViewItem];
      if (widthAndHeight &lt; 22) {
          widthAndHeight = 22;
      }
      CGFloat result = lroundf(widthAndHeight * self.venueLayoutZoom);
      return CGSizeMake(result, result);
  }
  
  - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
  {
      return 0;
  }
  
  - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  {
      return UIEdgeInsetsZero;
  }
  
  - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
  {
      return 0;
  }
  </code></pre>
  
  <p>For <code>UICollectionViewFlowLayout</code> I use <a href="https://github.com/akashraje/BidirectionalCollectionViewLayout" rel="nofollow noreferrer">this</a> because I need to scroll in both directions. Every time size is correct and without any float values. I always tried to modify <code>UICollectionView</code> width. For example: I have 29 elements in one row and I want it to be 11 px width each. Then I set up width to 319. </p>
  
  <p>And the second question is:
  I want to create cell with only right bottom rounded corner like <a href="https://i.stack.imgur.com/7n9z3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7n9z3.png" alt="enter image description here"></a>. But again iPhone 6 and up shows me wrong result such as <a href="https://i.stack.imgur.com/gWgly.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gWgly.png" alt="enter image description here"></a>. (look at this line on top). I want just a smooth colors. But when I scroll left/right it could be normal. </p>
  
  <p><code>UICollectionViewCell</code> code:</p>
  
  <pre><code>- (void)prepareForReuse
  {
      [self.circularLayer removeFromSuperlayer];
  }
  
  - (void)awakeFromNib
  {
      [super awakeFromNib];
      [self allocAndAddLayers];
  }
  
  - (void)allocAndAddLayers
  {
      self.circularLayer = [CALayer layer];
      [self.layer addSublayer:self.circularLayer];
  }
  
  - (void)layoutSubviews
  {
      [self updateRoundedCorners];
  }
  
  - (void)updateRoundedCorners
  {
     self.circularLayer.bounds = bounds;
          self.circularLayer.position = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
              CGRect rect = self.circularLayer.bounds;
              CGFloat radius = CGRectGetWidth(rect) / kVenueLayoutCellDefaultCornerRadiusDivider;
              UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:corners cornerRadii:CGSizeMake(radius, radius)];
              CAShapeLayer *maskLayer = [CAShapeLayer layer];
              maskLayer.frame = bounds;
              maskLayer.path = maskPath.CGPath;
              self.circularLayer.mask = maskLayer;
  }
  </code></pre>