У меня проблемы с установкой contentView.backgroundColor
пользовательских TableViewCell
на .clean
. Если я установлю его на любой цвет, он будет работать, но когда я выберу .clean
, он будет показывать фон. Я попытался присвоить ячейку contentView
ее собственной розетке, но ничего не изменилось.
Как всегда большое спасибо.
Это код для пользовательской ячейки:
class ProductCategoryTableViewCell: UITableViewCell {
// @IBOutlet weak var view: UIView!
@IBOutlet weak var bg: UIView!
@IBOutlet weak var categoryLabel: UILabel!
var category: String!
override func awakeFromNib() {
super.awakeFromNib()
configureUi()
}
override func prepareForReuse() {
super.prepareForReuse()
// Set your default background color, title color etc
configureUi()
}
func configureUi() {
let cornerRadius: CGFloat = 5
bg.layer.cornerRadius = cornerRadius
bg.layer.borderWidth = 1
bg.clipsToBounds = true
if Theme.selectedTheme == 1 {
if #available(iOS 11.0, *) {
// view.backgroundColor = UIColor.red //Theme.backgroundColor
contentView.backgroundColor = UIColor.clear
bg.backgroundColor = Theme.textFieldBackgroundColor
bg.layer.borderColor = Theme.accentColor?.cgColor
categoryLabel.backgroundColor = Theme.textFieldBackgroundColor
categoryLabel.textColor = Theme.textFieldTextColor
} else {
// Fallback on earlier versions
// view.backgroundColor = Theme.backgroundColorRgb
bg.backgroundColor = Theme.textFieldBackgroundColorRgb
bg.layer.borderColor = Theme.accentColorRgb.cgColor
categoryLabel.backgroundColor = Theme.textFieldBackgroundColorRgb
categoryLabel.textColor = Theme.textFieldTextColorRgb
}
} else if Theme.selectedTheme == 2 {
if #available(iOS 11.0, *) {
// view.backgroundColor = Theme.backgroundColor2
bg.backgroundColor = Theme.textFieldBackgroundColor2
bg.layer.borderColor = Theme.accentColor2?.cgColor
categoryLabel.backgroundColor = Theme.textFieldBackgroundColor2
categoryLabel.textColor = Theme.textFieldTextColor2
} else {
// Fallback on earlier versions
// view.backgroundColor = Theme.backgroundColorRgb2
bg.backgroundColor = Theme.textFieldBackgroundColorRgb2
bg.layer.borderColor = Theme.accentColorRgb2.cgColor
categoryLabel.backgroundColor = Theme.textFieldBackgroundColorRgb2
categoryLabel.textColor = Theme.textFieldTextColorRgb2
}
}
}
}
![Three](https://i.stack.imgur.com/d0Tt8.png)