简体   繁体   中英

UITableView last row separator is wrong color

I am on iOS 8. I add a view for the footer to stop empty rows at end of the UITableView with

- (UIView *)tableView:(UITableView *)tableViewIn viewForFooterInSection:(NSInteger)section

I have a custom separator colour for the table using

self.tableView.separatorColor = NAV_FG_COLOUR;

However the last row separator is defaulting back to white. Any ideas welcome.

  • Make sure you have set clipsToBounds to YES in your UITableViewCell . Otherwise there could be double _UITableViewCellSeparatorView in your cell. One of those will have wrong color for last cell.
  • if clipsToBounds is YES already then this white color is the background color of UITableViewCell itself. Because last cell doesn't have separator at all when footer view is set up for the table. However height of contentView of your last cell is still 0.5pt less than height of cell. So that it makes visible background color of the cell itself.

使用此设置分隔符颜色

[self.tableView setSeparatorColor:[UIColor redColor]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM