Removing cell borders from a section of grouped-style UITableView

后端 未结 15 2106
南旧
南旧 2020-12-04 07:56

I have a UITableViewController initialized with the grouped style and having multiple sections. For one of these sections, I\'d like its constituent cells to be completely t

相关标签:
15条回答
  • 2020-12-04 07:59

    If you have a custom UITableCellView then you can add the following method to your view to remove the background view.

    - (void)setBackgroundView:(UIView *)backgroundView
    {
        // We don't want background views for this cell.
        [super setBackgroundView:nil];
    }
    
    0 讨论(0)
  • 2020-12-04 08:04

    As of iOS 8, setting the separator attribute to none works as well.

    Get rid of cell border

    0 讨论(0)
  • 2020-12-04 08:05

    I just thought I would convert my comment to @Intentss into an answer, because it maybe useful for those, using his solution.

    Using iOS6.1 with a grouped UITabelView, using ARC:

    [tableView setSeparatorColor:[UIColor clearColor]];

    Does not work

    cell.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];

    Does work

    0 讨论(0)
  • 2020-12-04 08:06

    Try using tableView.separatorColor = [UIColor clearColor];

    And, don't use tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    I tested with both, if style is none, making the section borders invisible is not working, but instead just change its color, and section border will appear to be none.

    iOS seems to be differentiating making an object none and making an object transparent

    0 讨论(0)
  • 2020-12-04 08:07

    You have to actually set

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    

    to remove the border of cells.

    0 讨论(0)
  • 2020-12-04 08:09

    This is what worked for with having a Grouped style table

    [tableView setSeparatorColor:[UIColor clearColor]];

    0 讨论(0)
提交回复
热议问题