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

后端 未结 14 1027
礼貌的吻别
礼貌的吻别 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:13

    This is definitely help. Working. but set separator "none" from attribute inspector. Write following code in cellForRowAtIndexPath method

    if(indexPath.row==arrData.count-1){
     UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0,           
     cell.contentView.frame.size.height - 1.0,      
     cell.contentView.frame.size.width, 1)];
    
        lineView.backgroundColor = [UIColor blackColor];
        [cell.contentView addSubview:lineView];
    }
    

提交回复
热议问题