ios - Disclosure Indicator 背景后面的 Swift UITableViewCell 视图在明亮模式下没有变化
问题描述
我在更改 UITableViewCell 的背景颜色时遇到问题。
我将单元格的背景颜色设置为 UIColor.systemGray6 但是披露指示器周围的颜色仍然是白色。但在暗模式下,它可以正常工作,如下图所示:
这是我包含披露指标的单元格代码:
class SettingsDiscolsureCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
self.contentView.backgroundColor = UIColor.systemGray6
self.textLabel?.font = UIFont(name: "AvenirNext", size: UIFont.labelFontSize)
self.accessoryType = .disclosureIndicator
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
我试过self.accessoryView?.backgroundColor = .systemGray6
但注意到改变了
为什么会发生这种情况,我应该怎么做才能改变整个背景颜色?
解决方案
而不是为 UITableViewCell 的 contentView 分配颜色,使用这个
self.backgroundColor = UIColor.systemGray6
您的单元格背景颜色将显示在附件类型下方
推荐阅读
- node.js - 在 React 中发布数据 onClick
- mongodb - 如何在 MongoDB 聚合中添加自动递增字段?
- python - 在python中为多个变量分配多个值的问题
- python - 如何从 matpotlib 的子图中删除条形图?
- php - 根据 id 合并 Array 数据
- python - 应用自定义 groupby 聚合函数来查找 Numpy 数组的平均值
- python - 模板匹配 - 在 GUI 上匹配绘制形状
- node.js - Jhipster Prod 构建失败
- php - 运行 yarn start-debug-proxy 命令时出错
- python - 将字符串分隔到具有嵌套括号的列表中