title: How to make border on section of tableview
body: <p>I have to make shadow on section of tableview in ios. I have tried to make this with this method of table cell but it's not working.</p>
  
  <pre><code>(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  {
      NSLog(@"Section:%ld  row:%ld", indexPath.section, (long)indexPath.row);
  
      if ([cell respondsToSelector:@selector(tintColor)])
      {
  
          CGFloat cornerRadius = 5.f;
  
          cell.backgroundColor = UIColor.clearColor;
  
          CAShapeLayer *layer = [[CAShapeLayer alloc] init];
  
          CGMutablePathRef pathRef = CGPathCreateMutable();
  
          CGRect bounds = CGRectInset(cell.bounds, 0, 0);
  
          BOOL addLine = NO;
  
          if (indexPath.row == 0 &amp;&amp; indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1)
  
          {
               CGPathAddRoundedRect(pathRef, nil, bounds, 0.0, 0.0);
  
          } else if (indexPath.row == 0)
          {
  
          CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
  
          CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), 0.0);
  
          CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), 0.0);
  
    CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
          addLine = YES;
  
          } else if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1)
  
          {
  
          CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
  
          CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), 0.0);
          CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), 0.0);
          CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
          } else {
          CGPathMoveToPoint(pathRef, nil, bounds.origin.x, bounds.origin.y);
          CGPathAddLineToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
          CGPathMoveToPoint(pathRef, nil, CGRectGetMaxX(bounds), bounds.origin.y);
          CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
  
              addLine = YES;
          }
          layer.path = pathRef;
          CFRelease(pathRef);
          //set the border color
  
          layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
          layer.shadowRadius = 2;
          layer.shadowOpacity = 0.5;
          layer.strokeColor = [UIColor whiteColor].CGColor;
          layer.lineWidth = 1;
          if (addLine == YES)
          {
          CALayer *lineLayer = [[CALayer alloc] init];
          CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
          lineLayer.frame = CGRectMake(CGRectGetMinX(bounds), bounds.size.height-lineHeight, bounds.size.width, lineHeight);
          [layer addSublayer:lineLayer];
          }
  
  
          UIView *testView = [[UIView alloc] initWithFrame:bounds];
          [testView.layer insertSublayer:layer atIndex:0];
          testView.backgroundColor = [UIColor clearColor];
          cell.backgroundView = testView;
  
          testView.layer.shadowOffset = CGSizeMake(1, 1);
          testView.layer.shadowRadius = 2;
          testView.layer.shadowOpacity = 0.2;
          testView.layer.shadowColor = [UIColor blackColor].CGColor;
  }
          NSLog(@"END row:%ld", (long)indexPath.row);
  }
  </code></pre>
  
  <p>And I have to give shadow like this image:</p>
  
  <p><a href="https://i.stack.imgur.com/VccVW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VccVW.png" alt="enter image description here"></a></p>