更改表格视图的单元格选择颜色

时间:2010-10-18 20:16:20

标签: iphone

我们可以更改表格视图的选择颜色,即单元格,默认情况下是蓝色,那么,我们可以将其更改为任何其他颜色吗?

问候

2 个答案:

答案 0 :(得分:3)

这种方式在代码中

aCell.selectedBackgroundView = [[[UIImageView alloc] 
      initWithImage:[UIImage imageNamed:@"selectedBackground.png"]] autorelease];

或者您可以在界面构建器中将其设置为灰色,我认为蓝色和灰色是可用的而无需创建视图

答案 1 :(得分:3)

另一种方法是,不需要图像文件:

UIView *bgView = [[UIView alloc] init];
// At least on iOS6 you don't to size the view for this to work.
bgView.backgroundColor = [UIColor grayColor];
aCell.selectedBackgroundView = bgView;
相关问题