开发者

how to make the background of UITableView cell transparent in iphone?

I wrote the following code to make my cell transparent as I do with 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]];开发者_JS百科
return cell;

}

anybody can help me


In viewDidLoad you can simply add

self.tableView.backgroundColor = [UIColor clearColor];

You do not need to make your own view like you have above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜