开发者

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

开发者 https://www.devze.com 2023-02-24 09:50 出处:网络
I wrote the following code to make my cell transparent as I do with UITableView - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

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

精彩评论

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