4

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

enter image description here

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

customerTable.backgroundView = nil; 

Also in my xib I have cleared the background of my table.

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

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

As a result I am getting the above output.

The problem I am facing is the black corners I am getting in every cell. I know it has something to do with background of the cell but nothing is working for me. I also tried to clear the background of cell writing the following code line:

 cell.backgroundView = nil; 
6
  • Are you creating your own UITableViewCell subclass? Commented Jul 21, 2011 at 17:23
  • 2
    What happens if you set cell.backgroundColor = [UIColor clearColor]? Are the black corners still there? Commented Jul 21, 2011 at 17:30
  • No there are no corners now. But how do I get the background color of cell as I want to set and still get no corners? Commented Jul 21, 2011 at 17:34
  • 2
    You could try overriding how the cell is drawn or add another subview with rounded corners to the cell (while keeping the background color clear). How are you getting the rounded corners for the UITableViewCell? Commented Jul 21, 2011 at 17:39
  • 1
    I'm not sure why the black corners are coming up then, but instead of an image you could subclass UITableViewCell and draw a rounded rect instead of the basic drawing. That should let you control the corner roundness and the entire color of the cell while getting rid of the black corners. Commented Jul 21, 2011 at 17:55

6 Answers 6

8

Try

 customerTable.backgroundColor = [UIColor clearColor]; customerTable.opaque = NO; customerTable.backgroundView = nil; 
Sign up to request clarification or add additional context in comments.

4 Comments

I have already mentioned that I have cleared the background of table in my xib.
Setting opaque to NO is the key, I think.
Hi guys. I had already tried all what Perrie has suggested before posting this question. Nothing worked for me.
@Jolly : He is correct if it was table whose background I wanted to be clear. I have clearly mentioned, it is the cell inside the section of which I was worried about.
0

Just try with it:

Set the cell background view to YourcellImage & cells background color to clear 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; } 

Comments

0

Try this code.....

customerTable.separatorColor = [UIColor clearColor]; 

Comments

0

Try

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

1 Comment

This clears the background of cell. I want the color to be there but no black corners.
0

I was facing the same problem. And got to know It has nothing to do with cell's background.

The issue is with background of the tableview which causes this weird corners, So

self.tableview.backgroundColor = [UIColor clearColor]; 

in viewWillAppear will solve the issue :)

Comments

0

Clearing the background in the cellForRowAtIndex method should work

[cell setBackgroundColor:[UIColor clearColor]]; 

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.