I have a UIViewController
with a custom background color. On top of it there\'s a UITableView
with UITableViewCells
that are semi-transpar
Create a subclass of UITableViewCell(Such as named: CustomCell), and override the method in CustomCell.m :
- (id)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if(self){
// Initialization code
[self setBackgroundColor:[UIColor clearColor]];
UIView * bgView = [[UIView alloc] initWithFrame:self.frame];
[bgView setBackgroundColor:[UIColor colorWithWhite:1 alpha:0.5]];
[self addSubview:bgView];
}
return self;
}
Remove willDisplayCell method in MasterViewController.m
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5];
}
Change the cellForRowAtIndexPath
method in MasterViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
Change the cell's class type in storyboard
Just have a try :D