iOS如何给没有数据的cell隐藏分割线

应用场景:例如搜索时候只有一条数据,其他空白cell分割线隐藏起来

UIView *view = [[UIView alloc] init];
[view setBackgroundColor:[UIColor clearColor]];
self.tableView.tableFooterView = view;

为了方便其他地方用,可以给tableView写分类

@interface UITableView (Additions)
- (void)dx_hideTableEmptyDataSeparatorLine;
@end
- (void)dx_hideTableEmptyDataSeparatorLine {
    UIView *view = [[UIView alloc] init];
    [view setBackgroundColor:[UIColor clearColor]];
    self.tableFooterView = view;
}

你可能感兴趣的:(iOS如何给没有数据的cell隐藏分割线)