ableView是app開發中常用到的控件,功能很強大,多用於數據的顯示。下面給大家介紹設置UITableView的全屏分隔線的兩種方法。
具體詳情如下所示:
如圖 添加如下代碼
sTableView.separatorInset = UIEdgeInsetsZero; sTableView.layoutMargins = UIEdgeInsetsZero; cell.layoutMargins = UIEdgeInsetsZero;
第二種方法如下圖
-(void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; if ([_moreTableView respondsToSelector:@selector(setSeparatorInset:)]) { [_moreTableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)]; } if ([_moreTableView respondsToSelector:@selector(setLayoutMargins:)]) { [_moreTableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)]; } } -(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]; } }