1. 除掉UITableView底部多余行及分割线:
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
2. 隐藏所有的分割线
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
3. 设置分割线横条的颜色
self.tableview.separatorColor = [UIColor redColor];
4. 设置分割线横条的边距
- 方案1 - cellForRowAtIndexPath代理
//定制表格单元分割线
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ClientManageCell *cell = [tableView dequeueReusableCellWithIdentifier:kClientTableViewCellIdentifier];
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsMake(0, 25, 0, 0)];
}
//给cell的model赋值
cell.clientManageModel = self.sectionArr[indexPath.section][indexPath.row];
return cell;
}
//定制表格单元分割线
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsMake(0, 25, 0, 0)];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsMake(0, 25, 0, 0)];
}
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.tableView.tableFooterView = [UIView new];
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,15,0,0)];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
[self.tableView reloadData];
}
网友评论