界面IOS进阶iOS滚动视图tableview,collectionview

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

2016-03-07  本文已影响1426人  船长_

应用场景:例如搜索时候只有一条数据,其他空白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];
}
上一篇下一篇

猜你喜欢

热点阅读