我创建了一个自定义UITableViewCell.表格视图显示数据正常.我所困扰的是当用户触摸tableview的单元格时,我想显示除默认[蓝色]值以外的单元格的背景颜色,以突出显示单元格的选择.我使用这段代码但没有任何反应:
cell.selectedBackgroundView.backgroundColor=[UIColor blackColor];
Run Code Online (Sandbox Code Playgroud) 我想知道如何改变UITableViewCell任何想法的蓝色突出显示/选择颜色?
我有这样的菜单:

每个单元格的正常(未选定)状态是图像,所选状态也是图像(看起来像默认的蓝色图像).但是,我想添加一个额外的第三个图像,这样当用户选择一个单元格时,它会在变为蓝色(选中)之前短暂更改为第三个颜色.
这是我的代码:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView setBackgroundColor:[UIColor clearColor]];
NSString *cellIdentifier = @"MenuItemCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
UIImage *cellBackgroundNormal = [UIImage imageNamed:@"cell_menu_normal"];
UIImage *cellBackgroundSelected = [UIImage imageNamed:@"cell_menu_selected"];
UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:cellBackgroundNormal];
UIImageView *cellBackgroundSelectedView = [[UIImageView alloc] initWithImage:cellBackgroundSelected];
cell.backgroundView = cellBackgroundView;
cell.selectedBackgroundView = cellBackgroundSelectedView;
[cell.textLabel setBackgroundColor:[UIColor clearColor]];
[cell.textLabel setTextColor:[UIColor whiteColor]];
[cell.textLabel setFont:[UIFont boldSystemFontOfSize:17.0]];
cell.textLabel.text = [self.menuItems objectAtIndex:indexPath.row];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
如你所见,我现在只有两个州.我不知道如何cell.hoveredBackgroundView为第三张图片介绍某种形式.如果有人能帮我实现这一点,我真的很感激.