0

I've a grouped UITableView and I've set the background of one of its cells to be a gradient image, this way:

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"cell"];

   if (cell == nil) {
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

      cell.textLabel.text = NSLocalizedString(@"Add item", @"");
      cell.textLabel.backgroundColor = [UIColor clearColor];

      UIImage* image1 =[[UIImage imageNamed:@"gradient_normal"] stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0];
      UIImage* image2 =[[UIImage imageNamed:@"gradient_selected"] stretchableImageWithLeftCapWidth:5.0 topCapHeight:0.0];
      cell.backgroundView = [[UIImageView alloc] initWithImage:image1];
      cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:image2];
   }

return cell;
}

Background of the cell is correctly displayed, but it has not rounded corners anymore, as the rest of the cells at top and bottom of the table and with default background have... I tried setting the cornerRadius property of the table view, but it didn't work. And I was not able to set the cornerRadius for the particular cell.

The only post I found dealing with this same problem had not been actually answered (grouped tableViewCell - no rounded corner after setting the background of a grouped table cell), could somebody help me with this issue?

Thanks in advance

Community
  • 1
  • 1
AppsDev
  • 12,319
  • 23
  • 93
  • 186

1 Answers1

0

If you are allowed/able to use outside libraries, checkout PrettyKit, makes it quite easy.

If you have to do it on your own, the best way to go about this is to subclass UITableViewCell and create your own custom cells. Here is a good tutorial

kushyar
  • 1,191
  • 1
  • 6
  • 10
  • Thanks! I'll try to customize in my own in first instance, but I will consider the library you referred – AppsDev Jun 17 '13 at 13:42