UITableView Separator Style Question

前端 未结 3 1875
面向向阳花
面向向阳花 2020-12-10 17:09

I have a tableview that is blank by default. User can add cells to it.

I want the separator lines to be clear when there are no cells, and grey when there are cells

3条回答
  •  余生分开走
    2020-12-10 17:56

    This changes the boolean flag of whether there will be a separator or not. Put this in viewDidLoad:

    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    

    And to make sure you've really made it go away, set the seperatorColor property to whatever the background color of the view and cell would be:

    // If the background is white
    self.tableView.separatorColor = [UIColor whiteColor];
    

    So then even if somehow the above does not get called and the separator is still persisting - it would be the same color as what is behind it, therefore invisible.

    Good luck.

提交回复
热议问题