2011-04-11 58 views
0

我写了下面的代码,使我的细胞透明,因为我做的UITableView如何在iphone中使UITableView单元格的背景透明?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
static NSString *CellIdentifier = @"Nsubject"; 
SubjectsCell *cell = (SubjectsCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    [[NSBundle mainBundle] loadNibNamed:@"mySubjectCell" owner:self options:nil];  
    cell=subjCell; 
    UIView* backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ]; 

    cell.backgroundView = backgroundView; 
    for (UIView* view in cell.contentView.subviews) 
    { 
     view.backgroundColor = [ UIColor clearColor ]; 
    } 
} 
[cell SetTitle:[subjectsArr objectAtIndex:indexPath.row]]; 
return cell; 

}

有人能帮助我

回答

0

在viewDidLoad中,你可以简单地添加

self.tableView.backgroundColor = [UIColor clearColor]; 

您不需要像上面那样制作自己的视图。