【问题标题】:Changing standard UITableview selection color makes text invisible / covers text更改标准 UITableview 选择颜色使文本不可见/覆盖文本
【发布时间】:2016-07-22 08:00:50
【问题描述】:

我正在尝试更改我的 didSelectRowtIndexPath 中 UITableview 的选择颜色。

let selectedCellColor = UIColor.init(red: 97.0/255.0, green: 196.0/255.0, blue: 185.0/255.0, alpha: 1)

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
    print("tableView -> didSelectRowAtIndexPath")

    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath)
    cell.contentView.backgroundColor = selectedCellColor
    cell.backgroundColor = selectedCellColor
}

不幸的是,虽然选择颜色变化,但是当我这样做时,文本被覆盖/不可见。

我进行了一些搜索,但似乎这是更改标准 UITableView 单元格选择颜色的最推荐解决方案。

我还尝试更改标签颜色,认为它可能会变得可见但没有运气。

cell.textLabel?.textColor = UIColor.whiteColor()

我错过了什么?

【问题讨论】:

  • 你可能会找到答案here

标签: ios swift uitableview uicolor


【解决方案1】:

感谢@MudOnTire。但是,问题有点不同。似乎我的 textlabel.text 属性在选择时总是变空。由于我实际上并没有期待这样的事情,所以我从来没有费心去检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-08
    • 2020-11-23
    • 2013-08-04
    • 2023-03-18
    • 1970-01-01
    • 2019-07-10
    • 2023-01-12
    • 1970-01-01
    相关资源
    最近更新 更多