iphone中的小区选择方式

Sag*_*ari 3 iphone uitableview

默认情况下,iphone中有三种选择样式 - 表格视图.

灰色 - 蓝色 - 无.

我不需要灰色或蓝色.

我想设定我的习惯.

例如,在正常情况下,单元格应具有"aaaa.png"背景.

&Selected cell应该有"bbbbb.png"背景.

我试图应用cell.backgroundView和cell.selectedBackground视图.但它不起作用.

如果您对此有任何想法,请帮助我.

在此先感谢您的帮助.

小智 8

这里有三行代码,但您不需要图像!

UIView *selectedBackgroundViewForCell = [UIView new];
[selectedBackgroundViewForCell setBackgroundColor:[UIColor redColor]];
theCell.selectedBackgroundView = selectedBackgroundViewForCell;
Run Code Online (Sandbox Code Playgroud)


han*_*Dev 6

这是使用一行代码完成它的一种方法:

cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pink.png"]] autorelease];
Run Code Online (Sandbox Code Playgroud)

显然你需要制作图像.