title: iPhone - Create custom UITableViewCell top and bottom borders
body: <p>I have been looking everywhere and have not quite found my answer.</p>
  
  <p>I populating a UITableView with dynamic cells from JSON and I am trying to hide any extra cells. I turned off the separators in IB, and of course all the cell separators disappear. How do I add a line to the bottom and top of each tableviewcell so that only the cells that have information show a border? I have imported Quartz and have been playing with CALayer but can't find a solution.</p>
  
  <p>I found a similar question here, but the only answer was not very helpful.</p>
  
  <p>What would be a better, different way of doing this?</p>
  
  <p>Here are my cellForRowAtIndexPath and my numberOfRowsInSection:</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
  
      // Return the number of rows in the section.
      //set equal to the information in the array
  
      return [_jsonDataArray count];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  
      //create Dictionary of data in row
      NSDictionary *jsoninfo = [_jsonDataArray objectAtIndex:indexPath.row];
  
      //get required keys from dictionary and assign to vairables
      NSString *title = [jsoninfo objectForKey:@"title"];
      NSString *subtitle = [jsoninfo objectForKey:@"subtitle"];
      NSURL *imageURL = [NSURL URLWithString:[jsoninfo objectForKey:@"series_image_URL"]];
  
      //download the images.
      NSData *imgData = [NSData dataWithContentsOfURL:imageURL];
      UIImage *img = [[UIImage alloc] initWithData:imgData];
  
  
      //set boarder for custom cells... I need to have a border on the top and bottom of the cells I am creating so xcode does not autofill the empty space.
  
  
  
      //fill in text to cells
      cell.textLabel.text = title;
      cell.detailTextLabel.text = subtitle;
      cell.imageView.image = img;
  
      return cell;
  }
  </code></pre>