我可以使用突出显示表格视图单元格而没有目标c中的默认蓝色吗?

Ran*_*ana 1 iphone objective-c

我正在做一个项目,我需要使用突出显示的表视图颜色而不是默认.

Can*_*der 9

当然可以.

有两种方法可以实现这一目标:

  1. 使用UITableViewCellselectedBackgroundViewselectedTextColor性能
  2. 子类UITableViewCell并实现drawInRectsetSelected:animated:方法

后一种选择为您提供了更大的灵活性和更好的性能,但如果您以前没有使用过CoreGraphics,可能会稍微困难一些.

更新回应OP的评论:

以下是您可以使用该selectedBackgroundView属性的方法:

UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
[bgView setBackgroundColor:[UIColor redColor]];
[cell setSelectedBackgroundView:bgView];
[bgView release];
Run Code Online (Sandbox Code Playgroud)

我自己没试过,但它应该有效.