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

作者: 船长_ | 来源:发表于2016-03-07 22:06 被阅读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];
    }
    

    相关文章

      网友评论

      • 我是码神:关键是我原来的表是有FooterView的 这样一弄 我的FooterView不就没了 求解大神
        船长_:如果任何情况都有footerView,那就没有必要隐藏分割线
      • 可儿家族:这个在培训的时候,老师教了。不过还是要评论。
      • 834f65bae4f0:叼叼叼,跪服,之前一直都是自己先隐藏分割线 然后在cell里面加的,但是后来有的用户(尤其是经理)的iPhone设置的是大字体,跟着自定义的分割线也被拉伸了,显得特别粗,楼主救我于水火 :kissing_heart:
        我是码神:@suming1910 直接设置的话FooterView位置不对
        834f65bae4f0:@1529f9f30b9c 你有FooterView就直接设置啊 ,设置了FooterView自然就不会有多余的分割线显示了
        我是码神:关键是我原来的表是有FooterView的 这样一弄 我的FooterView不就没了 求解大神
      • 费宇超:self.tableView.tableFooterView = [[UIView alloc]init];

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

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