ios - 在 iOS 14 中更改 UITableViewCell 的背景颜色
问题描述
在我的 iOS 应用程序中,我想更改所选UITableViewCell
. 这就是我所拥有的,它运行良好,除了在 iOS 14 上我收到一条错误消息,说selectedBackgroundView
是nil
. 我需要在这里更改什么以便它也可以在 iOS 14 上运行?
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
self.selectedBackgroundView!.backgroundColor = selected ? UIColor.grey : .white
menuLabel.textColor = selected ? UIColor.darkGrey : UIColor.primaryDark
iconImageView.tintColor = selected ? UIColor.darkGrey : UIColor.primaryDark
}
解决方案
这对我有用:
self.contentView.backgroundColor = selected ? UIColor.grey : .white
推荐阅读
- javascript - 使用 drawImage 缩放上面的画布
- gradle - Groovy @CompileStatic 和 @TypeChecked 顺序、错误或误解
- php - 只为一个接口配置 openvpn 客户端
- c++ - 每次都出乎意料的结果
- python-3.x - 如何将单个字符与列表中的元素分开?
- android - 将对象添加到 firebase 实时数据库列表会将其转换为 HashMap。如何将其保留为列表或转换它
- go - 如何修复对象错误时未定义“名称”?
- sql-server - 如何将 mssql 中的维护计划备份错误“BackupIoRequest::ReportIoError: read failure on backup device ...”修复到共享文件夹
- node.js - 类型可以被promsified的函数
- hapijs - HapiJS 回复可读流