nath
nath

Reputation: 2848

Setting background color distort the Table cell

I have a grouped table view on one of my view. And inside the cellForRowAtIndexPath delegator method I have set background color for each table cell as follows.

UIColor *color = [UIColor colorWithRed:221.0/255 green:241.0/255 blue:249.0/255 alpha:1.0];
[cell.contentView setBackgroundColor:color];

Background color set without any problem. But problem occur in top and bottom cells. In top and bottom cells have curved edges. But when I add the background color it distort the edges. I have uploaded a print screen in such window.You can see the issue occure in the bottom cell where i have set the background color. Can some one please tell me how to solve this problem. enter image description here

Upvotes: 0

Views: 135

Answers (2)

Alex Terente
Alex Terente

Reputation: 12036

Use cell.backgroundColor = [UIColor redColor];

not

[cell.contentView setBackgroundColor:color];

A UITableViewCell is a more complex object than an object with a contentView propretry. You can find more about cell in UITableViewCell Class Reference

Upvotes: 1

user1340450
user1340450

Reputation:

Set the cell's clipsToBounds property to YES, that should make it respect rounded cell boundaries.

Upvotes: 0

Related Questions