title: Drawing dotted line between the cells of UICollectionView
body: <p>I have to achieve something like this(please check attached ScreenShot). The best possible solution which came to my mind is <code>UICollectionView</code>. I have created rounded border along the cell and put a button on the cell. Now for the dotted straight line I have used <code>CAShapeLayer</code> with <code>BezierPath</code> and added the layer to my <code>collectionview background with background color set to clear color</code>. Here comes the problem, I am not seeing any dotted line. Here is what I have tried. Now I have couple of questions. While answering please consider me as a beginner.</p>
  
  <p>1) Why my lines are not showing.<br>
  2) How to calculate the width between the two cell, right now i am setting a random number.<br>
  3) Is there any other approach which can solve this use-case more efficiently.  </p>
  
  <p><a href="https://i.stack.imgur.com/kmUf2.png"><img src="https://i.stack.imgur.com/kmUf2.png" alt="required"></a></p>
  
  <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  UIBezierPath *borderPath;
  CGFloat borderWidth;
  
  KKCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"testCell" forIndexPath:indexPath];
  borderPath = [UIBezierPath bezierPath];
  
  [borderPath moveToPoint:CGPointMake(cell.frame.origin.x + cell.frame.size.width -1 , cell.frame.origin.y + 2)];
  [borderPath addLineToPoint:CGPointMake(cell.frame.origin.x + cell.frame.size.width + 50,  cell.frame.origin.y +2)];
  borderWidth = 1.0;
  [self dottedLineWithPath:borderPath withborderWidth:borderWidth];
  return cell; 
  }
  
  /** creating dotted line **/
  
  - (void)dottedLineWithPath:(UIBezierPath *)path withborderWidth:(CGFloat)lineWidth
  {
  CAShapeLayer *shapelayer = [CAShapeLayer layer];
  shapelayer.strokeStart = 0.0;
  shapelayer.strokeColor = [UIColor blackColor].CGColor;
  shapelayer.lineWidth = borderWidth;
  shapelayer.lineJoin = kCALineJoinRound;
  shapelayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2 ], nil];
  shapelayer.path = path.CGPath;
  
  [self.milestoneCollection.backgroundView.layer addSublayer:shapelayer];
    }
  </code></pre>
  
  <p><strong>Here is what I have achieved till now</strong>.<a href="https://i.stack.imgur.com/g7AMQ.png"><img src="https://i.stack.imgur.com/g7AMQ.png" alt="enter image description here"></a></p>