Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS7 last cell in UITableView section forces full width separator

The UITableView below has custom UITableViewCells and I can adjust the separators fine using this line in the custom UITableViewCell:

self.separatorInset = UIEdgeInsetsMake(0, kDefaultSeparatorLeftInset, 0, 0); 

However the cell at the bottom of the section has a default separator that overrides the custom UIEdgeInsets that I set.

I'd like all the separators to be the same width, is there any way of doing this without redrawing the separators manually?

UITableView with wide section separator in iOS7

like image 763
Tim Windsor Brown Avatar asked Oct 01 '13 13:10

Tim Windsor Brown


1 Answers

After some experimentation I've found the only real solution is to set the UITableViewStyle to UITableViewStylePlainand set empty footers using:

-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {     return [[UIView alloc] initWithFrame:CGRectZero]; }  -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {     return 0.01f; } 

This will not be a satisfactory solution for some, because UITableViewStylePlain does not provide all of the features of UITableViewStyleGrouped, but it gives me the section without the full-width separator.

enter image description here

like image 66
Tim Windsor Brown Avatar answered Sep 24 '22 02:09

Tim Windsor Brown