UITableView空单元格不使用填充单元格的背景颜色

时间:2014-10-12 02:23:12

标签: ios xcode uitableview background-color

如何使下面为空的单元格具有与表格中第一项不透明度相同的背景颜色?我也希望保留我的圆角但是在这些空单元格上获得背景颜色时会出现问题,同时保持表格不透明以查看背景。

- (void)viewDidLoad {
    self.itemsTableView.layer.cornerRadius = 5;
    [super viewDidLoad];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)tableCell forRowAtIndexPath:(NSIndexPath *)indexPath {

    UIView* myBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
    myBackgroundView.backgroundColor = [UIColor blackColor];

    myBackgroundView.opaque = NO;
    myBackgroundView.alpha = 0.7;

    tableCell.backgroundView = myBackgroundView;
    tableCell.opaque = NO;
    tableCell.alpha = 0.7;
}

enter image description here

0 个答案:

没有答案