2011-04-11 55 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]; 

您不需要像上面那樣製作自己的視圖。