UITableView: the proper way to display a separator for the last cell

后端 未结 14 1021
礼貌的吻别
礼貌的吻别 2020-12-29 02:23

The question is what\'s the right-most way to display a separator in the last cell in a table/section.

Basically this is what I am after.

14条回答
  •  甜味超标
    2020-12-29 02:52

    You can do something like this if you are not using sections:

    - (void)viewDidLoad
    {
         self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(insetLeftSide, 0, width - insetRightSide, 1)];
    }
    

    If you are using sections implement the footer in each section as a one point View in the methods

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    {
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    {
    }
    

    This will allow you to have a separator for your last cell which in fact is not a separator is a footer that you can play with it and make it look like a separator

提交回复
热议问题