UItableviewcell textlabel背景颜色问题

时间:2011-03-21 14:34:59

标签: iphone uitableview background-color

cell.textLabel.backgroundColor = [UIColor clearColor];

在iPad3.2.2中不起作用,但在4.2中工作正常。

任何人都可以帮助清除单元格文本背景颜色。

我的要求是什么,我需要清楚地显示cell.backgroundView

提前致谢

3 个答案:

答案 0 :(得分:1)

默认情况下,UIKit会在选择时设置所有子视图的backgroundColor。

如果你想要一些不同的子类UITableViewCell并将这个方法添加到你的子类:

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    [[self textLabel] setBackgroundColor:[UIColor clearColor]];
    [[self detailTextLabel] setBackgroundColor:[UIColor clearColor]];
}

答案 1 :(得分:0)

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

  [[cell textLabel]setBackground:[UIColor clearColor]];

}

试试这个兄弟,我希望在iOS版本中工作正常。

答案 2 :(得分:0)

我在运行4.3.3的iPad上遇到同样的问题。

[cell.textLabel setBackgroundColor:[UIColor grayColor]];

这对我有用。

背景色是一场真正的噩梦! 祝你好运

相关问题