相关疑难解决方法(0)

UITableView Cell选择了Color?

我创建了一个自定义UITableViewCell.表格视图显示数据正常.我所困扰的是当用户触摸tableview的单元格时,我想显示除默认[蓝色]值以外的单元格的背景颜色,以突出显示单元格的选择.我使用这段代码但没有任何反应:

cell.selectedBackgroundView.backgroundColor=[UIColor blackColor];
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios selection-color

310
推荐指数
15
解决办法
31万
查看次数

如何更改UITableViewCell的蓝色突出显示颜色?

我想知道如何改变UITableViewCell任何想法的蓝色突出显示/选择颜色?

uitableview ios

126
推荐指数
10
解决办法
12万
查看次数

选择时如何更改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为第三张图片介绍某种形式.如果有人能帮我实现这一点,我真的很感激.

colors objective-c uitableview ios

46
推荐指数
6
解决办法
9万
查看次数

标签 统计

ios ×3

uitableview ×3

objective-c ×2

colors ×1

selection-color ×1