Removing cell borders from a section of grouped-style UITableView
Solution 1:
NOTE: This doesn't appear to be working in iOS7 and above. For iOS7 try this answer.
For iOS6 and below, to remove the grouped background from a cell in a grouped table view cell:
This didn't work
cell.backgroundView = nil; // Did Not Work
This did
cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
If you have moved to ARC (I've heard this works, but haven't tested it)
cell.backgroundView = [UIView new];
Solution 2:
You have to actually set
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
to remove the border of cells.
Solution 3:
The following hack works in iOS 7 – for now. :)
Subclass UITableViewCell
, and use this cell for the section that shouldn't have separators.
Override the addSubview
method in your cell subclass:
-(void)addSubview:(UIView *)view
{
// The separator has a height of 0.5pt on a retina display and 1pt on non-retina.
// Prevent subviews with this height from being added.
if (CGRectGetHeight(view.frame)*[UIScreen mainScreen].scale == 1)
{
return;
}
[super addSubview:view];
}
Solution 4:
This is what worked for with having a Grouped style table
[tableView setSeparatorColor:[UIColor clearColor]];