美文网首页ios开发的那些坑
iOS -tableView在Grouped样式下去掉secti

iOS -tableView在Grouped样式下去掉secti

作者: fly大梦想家 | 来源:发表于2018-02-28 16:45 被阅读12次
self.tableview = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
 [self.view addSubview: self.tableview];

理论上来讲写完上面的cell的分割线没有了,但是我需要很多个section,带header的,因为不需要footer,习惯上我会把footer的高度设置为0.1,(因为不设置的话会默认显示,高度目测是20的浅灰条)

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *footerView = [UIView new];
    footerView.backgroundColor = [UIColor redColor];
    return footerView;
}

写完发现每个section的headerView上面都有一条灰色的分割线,这条灰色的线后来证实不是分割线,就是自己设置的高度为0.1的footerView
不知道有什么办法能让这个footer不显示,所以就将footer的背景色设置成了和headerView一样的颜色,视觉上最起码看不到

相关文章

网友评论

    本文标题:iOS -tableView在Grouped样式下去掉secti

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