UITableView Separator Style Question

前端 未结 3 1867
面向向阳花
面向向阳花 2020-12-10 17:09

I have a tableview that is blank by default. User can add cells to it.

I want the separator lines to be clear when there are no cells, and grey when there are cells

3条回答
  •  感情败类
    2020-12-10 18:09

    A quick fix I usually do is:

    #pragma mark - UITableViewDelegate
    
    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
        if ([tableView respondsToSelector:@selector(setSeparatorStyle:)]) {
            [tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        }
    }
    

提交回复
热议问题