iOS7上的UITableView分隔符颜色错误

iOS7上的UITableView分隔符颜色错误,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我正在通过以下方式设置UITableView分隔符颜色: - (void)viewDidLoad { [super viewDidLoad]; self.tableView.separatorColor = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.1f]; } 和有时在iOS7上我的表格视图分隔符看起来不同(我猜带数据的单元格和空单元格分隔符的alpha不同),请查看附件图像: 如何解决此问题?如果要删除

我正在通过以下方式设置
UITableView
分隔符颜色:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.separatorColor = [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:0.1f];
}
有时iOS7上我的表格视图分隔符看起来不同(我猜带数据的单元格和空单元格分隔符的alpha不同),请查看附件图像:


如何解决此问题?

如果要删除所有包含空内容的单元格分隔符,请使用以下代码行

self.tableView.tableFooterView = [[UIView alloc] init]; 
viewDidLoad
方法中

其他方面设置
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone
并设置分隔符的自定义
UIImage

EX:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier = @"cell"; //[NSString stringWithFormat:@"S%1dR%1d", indexPath.section, indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        .
        . // your other code.
        .
        UIImageView *imgLine = [[UIImageView alloc] init];
        imgLine.tag = 101;
        [cell.contentView addSubview: imgLine];
     }

        .
        . // your other code.
        .

     UIImageView *imgLine = (UIImageView *) [cell.contentView viewWithTag:101];
     imgLine.frame =  CGRectMake(5, 69, 310, 1);
     imgLine.image = [UIImage imageNamed:@"queTblLine.png"];

     return cell;
}
不要忘记设置self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone

EDITE: 不确定,但对您的情况可能有帮助:

设置self.tableView.separatorInset=UIEdgeInsetsZero


获取

交换两条语句的顺序。首先设置颜色,然后设置插图:

self.tableView.separatorColor = [UIColor redColor];
self.tableView.separatorInset = UIEdgeInsetsZero;

您可以在故事板或nib/xib中直观地实现这一点

将UIImageView放置在单元格的底部边缘,您可以根据需要设置图像

步骤1:根据图像设置分割器

步骤2:将分隔符样式设置为“无”


您可以通过编程进行设置:

- (void)viewDidLoad {
   [super viewDidLoad];

   [[UITableView appearance] setSeparatorColor:[UIColor redColor]];

}

@santhu前两个分隔符明显比分隔空白单元格的颜色暗。谢谢,但我不想“删除”空单元格,我希望空单元格的分隔符颜色与包含数据的单元格的分隔符颜色相同。然后您可以使用我的另一个建议,这对您来说也是最好和简单的:)如何为表分隔符设置UIImage?将UIImageView添加为单元子视图?使用了最后一个选项(即),并且似乎工作正常。谢谢!设置self.tableView.separatorInset=UIEdgeInsetsZero和工作像一个魅力!!!非常感谢!:)