UITableViewCell Transparent Background - Grouped UITableView

I am trying to display my data in a grouped table as shown below:

enter image description here

As you can see, I cleared the background view for the table by writing the following code in viewDidLoad :

customerTable.backgroundView = nil; 

Also in my xib, I cleaned the background of my table.

In cellForRowAtIndexPath I set the background color for each cell in the table.

 cell.backgroundColor = [UIColor colorWithRed:255.0/255 green:235.0/255 blue:178.0/255 alpha:1]; 

As a result, I get the above conclusion.

Problem :

The problem I am facing is black corners . I fall into every cell. I know this has something to do with the background of the cell, but nothing works for me. I also tried to clear the cell background by typing the following line of code:

  cell.backgroundView = nil; 

Can someone help me get rid of these black corners?

Thanks,
Nitish

+4
source share
6 answers

Just try:

Set the background color of the cell to the background color of YourcellImage and cells to clear the color.

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; [cell setBackgroundColor:[UIColor clearColor]]; UIImage *backgroundImage = nil; UIImageView *backgroundView = nil; backgroundImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"YourYellowCellImage"ofType:@"png"]]; backgroundView = [[UIImageView alloc]initWithImage:backgroundImage]; backgroundView.frame = CGRectMake(0, 0, 600, 80); // Over here give your cell size cell.backgroundColor = [UIColor clearColor]; cell.backgroundView =backgroundView; [backgroundView release]; } //Over your set your Label Value return cell; } 
0
source

Try

  customerTable.backgroundColor = [UIColor clearColor];
 customerTable.opaque = NO;
 customerTable.backgroundView = nil;
+8
source

Try this code .....

 customerTable.separatorColor = [UIColor clearColor]; 
0
source

Try

 - (void)tableView: (UITableView*)tableView willDisplayCell: (UITableViewCell*)cell forRowAtIndexPath: (NSIndexPath*)indexPath { cell.backgroundColor = [UIColor clearColor]; } 
0
source

I had the same problem. And I learned that this has nothing to do with the background of the cell.

The problem is the background of the table, which causes these strange angles, So

 self.tableview.backgroundColor = [UIColor clearColor]; 

in viewWillAppear solves the problem :)

0
source

Background cleaning in cellForRowAtIndex method should work

 [cell setBackgroundColor:[UIColor clearColor]]; 

try also to clear the background in viewWillAppear, and if something strange happens, clear the project and rebuild.

0
source

All Articles