iOS-UITableviewcell分割线位置

这几天又遇到要调节列表分割线位置,就想起很久以前刚做时的做法:把自带的分割线隐藏,然后自己加一条UIView,不过现在不那么干了,把这个方法贴出来;

在 Tableview 的代理方法中,实现下面的代理方法:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//    [cell setSeparatorInset:UIEdgeInsetsZero];
    [cell setSeparatorInset:UIEdgeInsetsMake(0, 5, 0, 5)];
}

UIEdgeInsetsMake(上,左,下,右)自己可以调节,UIEdgeInsetsZero是左右两边都距离边缘零; 现在不考虑iOS7了,直接用 setSeparatorInset 方法就可以了。

原文地址:https://www.cnblogs.com/wangkejia/p/8000536.html