1. 程式人生 > >解決tableView分割線不頂頭

解決tableView分割線不頂頭

第一種(不自己劃線)

第一步

//1.解決tableView分割線不頂頭

    if ([self.table respondsToSelector:@selector(setSeparatorInset:)])[self.table setSeparatorInset:UIEdgeInsetsZero];

    if ([self.table respondsToSelector:@selector(setLayoutMargins:)]) [self.table setLayoutMargins:UIEdgeInsetsZero];

第二步

//2.解決tableView分割線不頂頭

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) [cell setSeparatorInset:UIEdgeInsetsZero];

    if ([cell respondsToSelector:@selector(setLayoutMargins:)])[cell setLayoutMargins:UIEdgeInsetsZero];

}

第二種

自定義cell在cell中自己畫線

先寫一下這句話  把tableView 的自帶分割線刪除

self.table.separatorStyle = UITableViewCellSeparatorStyleNone;

然後在自定義cell裡面

寫一個view 在最底部  當做分割線  就好了。