2010-10-17 110 views
0

它看起来很简单,但我不知道为什么我无法更改我工作的自定义标签的背景颜色。请检查我的代码下面的自定义单元格。更改自定义单元格的背景颜色

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 

    if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { 

     self.textLabel.backgroundColor = [UIColor clearColor]; 
     self.textLabel.textColor = [UIColor orangeColor]; 
     self.textLabel.text = @"lklklk"; 
     self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
     self.contentView.backgroundColor = [UIColor blackColor]; 
     self.accessoryView.backgroundColor = [UIColor blackColor]; 
    } 

    return self; 

} 

该电池只能用白色化背景显示上面的文字

在此先感谢

回答

2

我不得不应对这一挑战自己的Spring Cleaning

工作,而这里是如何我解决了问题:

UIView *view = [[UIView alloc] initWithFrame:CGRectZero]; 
view.backgroundColor = [UIColor blackColor]; 
view.opaque = YES; 
self.backgroundView = view; 
[view release]; 
+0

谢谢雅各的回复,但它没有设置完整的单元格的背景颜色。配件箭头仍然有白色背景,这看起来不太好,我需要完整的黑色背景 – pankaj 2010-10-17 07:44:52

+0

@ pankaj,现在就试试。 – 2010-10-17 07:47:23

+0

试过,但仍然没有成功 – pankaj 2010-10-17 07:51:50

0

UITa bleViewCells有一个backgroundView,你需要隐藏,以设置backgroundColor:

[self.backgroundView setHidden:YES]; 
self.backgroundColor = [UIColor clearColor]; 
self.opaque = NO; 
相关问题