【问题标题】:Show highlighted image in UITableViewCell在 UITableViewCell 中显示突出显示的图像
【发布时间】:2011-10-29 18:04:14
【问题描述】:

我已将图像和背景图像设置为 UITableViewCell。 但是当我点击它时,它显示的是标准的蓝色高亮而不是我的。

你知道我可以如何改变这种机制吗?

谢谢,尼尔斯

【问题讨论】:

    标签: ios uitableview highlight


    【解决方案1】:

    在您的表格视图委托中使用它:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        cell.backgroundColor = [UIColor redColor];
    }
    

    您还可以将单元格的 selectedBackgroundView 设置为自定义视图并设置其背景颜色。

    【讨论】:

    • 不。我不使用背景色,我使用的是背景视图。而且我可以看到我定义的标准视图,而不是突出显示的。
    • backgroundView是普通的backgroundView,selectedBackgroundView是cell被选中时使用的,但只有存在时才使用。
    【解决方案2】:

    你只需要设置两个UITableViewCell 属性backgroundView 和selectedBackgoundView。 iOS 将完成剩下的工作。

    【讨论】:

      猜你喜欢
      • 2011-04-14
      • 2016-03-19
      • 2016-02-05
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多