美文网首页
iOS如何给没有数据的cell隐藏分割线

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

作者: super_2e20 | 来源:发表于2021-01-13 17:44 被阅读0次

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

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

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

@interface UITableView (additions)
- (void)dx_hideTableEmptyDataSeparatorLine;
- (void)dx_scrollToTop;
@end

- (void)dx_hideTableEmptyDataSeparatorLine {
    UIView *view = [[UIView alloc] init];
    [view setBackgroundColor:[UIColor clearColor]];
    self.tableFooterView = view;
}
// 多添加一个滚动到顶部的方法,方便用
- (void)dx_scrollToTop {
    [self setContentOffset:CGPointZero animated:YES];
}

</article>

相关文章

网友评论

      本文标题:iOS如何给没有数据的cell隐藏分割线

      本文链接:https://www.haomeiwen.com/subject/jyhpaktx.html