不用这么麻烦了,在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
中加这两句代码就OK了。
[cell setLayoutMargins:UIEdgeInsetsZero];
[cell setSeparatorInset:UIEdgeInsetsZero];
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
if ([_tableVIew respondsToSelector:@selector(setSeparatorInset:)]) {
[_tableVIew setSeparatorInset:UIEdgeInsetsZero];
}
if ([_tableVIew respondsToSelector:@selector(setLayoutMargins:)]) {
[_tableVIew setLayoutMargins:UIEdgeInsetsZero];
}
}
-(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:UIEdgeInsetsZero];
}
}