美文网首页
IOS tableView 分割线处理

IOS tableView 分割线处理

作者: 奋斗吧_程序猿 | 来源:发表于2018-06-11 17:06 被阅读19次

1.取消多余的分割线

  • swift
self.tableView?.tableFooterView = UIView()
  • OC
self.tableView.tableFooterView = [[UIView alloc] init]; 

2.处理分割线对齐问题

  • 分割线不对齐左侧默认留出15点空白
//然后在UITableView的代理方法中加入以下代码
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)])
       {
          [cell setSeparatorInset:UIEdgeInsetsZero];
       }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)])
       {
         [cell setLayoutMargins:UIEdgeInsetsZero];
       }
}
  • 不对齐设置方法二:
self.tableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);

相关文章

网友评论

      本文标题:IOS tableView 分割线处理

      本文链接:https://www.haomeiwen.com/subject/demheftx.html