在簡書上看了一位大神的方法,獲益匪淺,在此記錄下來
此方法使用于iOS8.0之后
在viewDidLoad中實現(xiàn)兩行代碼
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
然后在willDisplayCell里面實現(xiàn)兩行代碼
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[cell setSeparatorInset:UIEdgeInsetsZero];
[cell setLayoutMargins:UIEdgeInsetsZero];
}
很簡單的方法,就能實現(xiàn)cell分割線拉伸至左右屏幕頂端啦