IOS 设置 UItableViewCell 分割线全屏

1. 干掉系统的 self.leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

然后自己添加UIView覆盖

2.利用系统的属性设置

IOS7:self.leftTableView.separatorInset = UIEdgeInsetsZero; 

IOS8:  在tableiview的代理方法- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 设置cell的layoutMargins 属性,为了适配IOS7,故设置如下

 if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {

        cell.layoutMargins = UIEdgeInsetsZero;

    }

3.重写cell的setFrame属性:万能的

3.1 取消系统的分割线 self.leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone

3.2 设置tableView的分割线颜色为分割线颜色

3.3 setFrame 在setFrame之前吧高度减1

- (void)setFrame:(CGRect)frame{

    frame.size.height -= 1;

    [super setFrame: frame];

}

3.4 一定要记得补回分割线高度

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 50+1;

}

猜你喜欢

转载自blog.csdn.net/qq_33726122/article/details/81454033