而不是使用图层,你可以添加一个视图到您想要的单元格的contentView,这添加1px的边框:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ... UIView *right = [[UIView alloc] initWithFrame:CGRectMake(319, 0, 1, cell.frame.size.height)]; right.backgroundColor = [UIColor redColor]; [cell.contentView addSubview:right];