Marks

iOS开发者,喜欢研究技术。

0%

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

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

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

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

1
2
3
@interface UITableView (Additions)
- (void)mnz_hideTableEmptyDataSeparatorLine;
@end
1
2
3
4
5
- (void)mnz_hideTableEmptyDataSeparatorLine {
UIView *view = [[UIView alloc] init];
[view setBackgroundColor:[UIColor clearColor]];
self.tableFooterView = view;
}