gpt4 book ai didi

ios - 更改标准 UITableview 选择颜色使文本不可见/覆盖文本

转载 作者:行者123 更新时间:2023-11-30 13:33:01 25 4
gpt4 key购买 nike

我正在尝试更改 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
}

不幸的是,当选择颜色发生变化时,当我执行此操作时,文本会被覆盖/不可见。

enter image description here

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

我还尝试更改标签颜色,认为它可能会可见,但没有成功。

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

我缺少什么?

最佳答案

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

关于ios - 更改标准 UITableview 选择颜色使文本不可见/覆盖文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36374518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com