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

后端 未结 14 1031
礼貌的吻别
礼貌的吻别 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 03:12

    The code below worked for me:

    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 0.35)];
    footerView.backgroundColor = [UIColor whiteColor];
    CGRect frame = footerView.frame;
    frame.origin.x = 15;
    frame.size.width = frame.size.width - 15;
    UIView *blackView = [[UIView alloc] initWithFrame:frame];
    [blackView setBackgroundColor:[UIColor blackColor]];
    blackView.alpha = 0.25;
    [footerView addSubview:blackView];
    tableView.tableFooterView = footerView;
    

    Hope it works for you too.

提交回复
热议问题