1、隱藏UITableViewCell分割線
? ? ? self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
2、UITableViewCell分割線左邊對齊
第一種方法:
//在創(chuàng)建talbleView的下方添加這兩個(gè)if
if ([myTableView respondsToSelector:@selector(setSeparatorInset:)]) {
myTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
if ([myTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[myTableView setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];
}
//實(shí)現(xiàn)tableview的代理方法
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];
}
}
第二種方法
cell.preservesSuperviewLayoutMargins=NO;
cell.separatorInset=UIEdgeInsetsZero;
cell.layoutMargins=UIEdgeInsetsZero;
3、修改UITableViewCell分割線的顏色
[self.tableviewsetSeparatorColor:[UIColor colorWithHexString:@"eeeeee"]];
4、隱藏表視圖多余單元格的分割線,此方法在創(chuàng)建talbeview的后面調(diào)用
- (void)setExtraCellLineHidden: (UITableView*)tableView{
UIView*view = [UIViewnew];
view.backgroundColor= [UIColorclearColor];
[tableViewsetTableFooterView:view];
}