您可以使用以下任何一种 sn-ps 代码来隐藏UITableView 的标准分隔线。
添加自定义分隔符最简单的方法是添加一个简单的UIView,高度为 1px:
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
separatorLineView.backgroundColor = [UIColor clearColor]; // set color as you want.
[cell.contentView addSubview:separatorLineView];
或
self.tblView=[[UITableView alloc] initWithFrame:CGRectMake(0,0,320,370) style:UITableViewStylePlain];
self.tblView.delegate=self;
self.tblView.dataSource=self;
[self.view addSubview:self.tblView];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];
v.backgroundColor = [UIColor clearColor];
[self.tblView setTableHeaderView:v];
[self.tblView setTableFooterView:v];
[v release];
或
- (float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
// To "clear" the footer view
return [[UIView new] autorelease];
}
或
还要检查nickfalk's answer,它非常简短且很有帮助。
你也应该试试这条线,
self.tableView.tableFooterView = [[UIView alloc] init];
不确定,但它适用于我检查过的所有 iOS 版本,包括 iOS 5 及更高版本,直至 iOS 7。