1
MyTableCell *cell=[[MyTableCell alloc]init];
cell.backgroundColor = [UIColor clearColor];

The above lines of code are still showing the white color of the cell's background and hiding the background image of the tableview.

rmaddy
  • 314,917
  • 42
  • 532
  • 579

5 Answers5

2

Go to you storyboard and set the color of your uitableview cell to clear color from there.And also set uitabelview color also to clear color.

Or in you viewdidload set tableview background color to clear color and in cellforrow at indexparth delagate set

cell.contentView.backGroundColor = [UIColor ClearColor]
Raman Srivastava
  • 396
  • 1
  • 14
  • please tell how can I add gap between two cells in the tableview? –  Jun 29 '17 at 07:34
  • If You want to do it programatically , then simply add following code in you cell for row at indexpath delegate : UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, 3)];/// change size as you need. separatorLineView.backgroundColor = [UIColor blackColor];// you can also put image here [cell.contentView addSubview:separatorLineView]; – Raman Srivastava Jun 29 '17 at 07:36
  • will try it and get back to u –  Jun 29 '17 at 07:37
  • I don't want to insert a separator line I just want gap in between them –  Jun 29 '17 at 07:39
  • Go to you Storyboard , then in you tableview cell add a view inside it leaving gaps from top and bottom . Use the gap according to your need. Then add all the controllers like label , button etc in the view. Set border of the view if you want . you will achieve hat you want. – Raman Srivastava Jun 29 '17 at 07:47
0

set the contentview background color also

cell.contentView.backGroundColor = [UIColor ClearColor];
cell.backGroundView.backGroundColor = [UIColor ClearColor];
cell.selectedBackGroundView.backGroundColor = [UIColor ClearColor];

Also check if you cleared the tableView.backGroundColor also

Amal T S
  • 3,327
  • 2
  • 24
  • 57
0

You can do it this way

cell.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];
halfer
  • 19,824
  • 17
  • 99
  • 186
Janmenjaya
  • 4,149
  • 1
  • 23
  • 43
0

try this

- (void)tableView:(UITableView *)tableView willDisplayCell(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath
{
 [cell setBackgroundColor:[UIColor clearColor]];
}
adarshaU
  • 950
  • 1
  • 13
  • 31
0

Thank you every one. I have solved the problem. I changed the background attribute in the attribute inspector in the storyboard for my cell object from default to clear color and it worked.