Swift Disclosure Indicator 背景后面的 UITableViewCell 视图在明亮模式下没有变化
Swift UITableViewCell view behind Disclosure Indicator background is not changing in bright mode
我在更改 UITableViewCell 的背景颜色时遇到问题。
我设置Cell的背景色为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
您的单元格背景颜色将显示在 accessoryType 下方
我在更改 UITableViewCell 的背景颜色时遇到问题。
我设置Cell的背景色为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
您的单元格背景颜色将显示在 accessoryType 下方