如何删除顶部的UITableView灰色线

初始化UIViewController代码:

self.view.backgroundColor= [UIColor whiteColor]; CGSize boundsSize = self.view.bounds.size; CGRect rectTableViewFrame = CGRectMake(0, 0, boundsSize.width, boundsSize.height - 64); UITableView* contentTableView = [[UITableView alloc] initWithFrame:rectTableViewFrame]; contentTableView.backgroundColor = [UIColor clearColor]; contentTableView.separatorColor = [UIColor clearColor]; contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

接下来在UITableView自定义视图(标题)中添加:

  CustomView* customView = [[CustomView alloc] init]; CGRect customViewFrame = customView.frame; customViewFrame.origin.y = - customView.size.height; customView.frame = customViewFrame; contentTableView.contentOffset = CGPointMake(0, customViewFrame.origin.y); contentTableView.contentInset = UIEdgeInsetsMake(customViewFrame.frame.size.height, 0, 0, 0); [contentTableView addSubview: customView]; 

问题:当滚动contentTableView的顶部customView有一个灰色的线…如何删除这个? 我不使用方法:

  -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 

但如果使用简单的视图与白色的背景颜色没有线。

你可以尝试设置不行样式:

 contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone; 

并在你的UITableViewCell底部添加一条灰线。