美文网首页
给UITableView设置分割线

给UITableView设置分割线

作者: FMG | 来源:发表于2016-06-23 11:44 被阅读44次

方法一:


// 去掉系统分割线
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

// 换成自己的分割线
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(15, 0, Screen_width - 15, 0.5)];
    line.backgroundColor = YHYCellSeparatorLineColor;
    [cell addSubview:line];   
}

方法二:

// 直接修改系统分割线位置
 if ([tableV respondsToSelector:@selector(setSeparatorInset:)]) {
                [tableV setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
            }

相关文章

网友评论

      本文标题:给UITableView设置分割线

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