UITableViewCell 分割线如何满屏

在iOS7中,UITableViewCell左侧会有默认15像素的空白。设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉。

但是在iOS8中,设置setSeparatorInset:UIEdgeInsetsZero 已经不起作用了。下面是解决办法

在UITableView的代理方法中加入以下代码 

 1 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
 2 
 3 {
 4 
 5     if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
 6 
 7         [cell setSeparatorInset:UIEdgeInsetsZero];
 8 
 9     }
10 
11     if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
12 
13         [cell setLayoutMargins:UIEdgeInsetsZero];
14 
15     }
16 
17 }    
原文地址:https://www.cnblogs.com/qq744890760/p/5127264.html