when selecting a cell in tableview : set background color to blue

This commit is contained in:
Johan Degraeve 2021-03-08 21:13:55 +01:00
parent 7437b73498
commit 48ca2795b4
2 changed files with 34 additions and 0 deletions

View File

@ -6,4 +6,7 @@ enum ConstantsUI {
/// color for section titles in grouped table views, example in settings view
static let tableViewHeaderTextColor = UIColor.systemBlue
/// color to use as background when a row is selected
static let tableRowSelectedBackGroundColor = UIColor.systemBlue
}

View File

@ -6,4 +6,35 @@ class SettingsTableViewCell: UITableViewCell {
static let reuseIdentifier = "SettingsCell"
/// single instance of a view with backgroundColor = custom color
private static var selectedBackGroundView: UIView = {
let backgroundView = UIView()
backgroundView.backgroundColor = ConstantsUI.tableRowSelectedBackGroundColor
return backgroundView
}()
override
init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// will set color when selected to own color
selectedBackgroundView = SettingsTableViewCell.selectedBackGroundView
}
required
init?(coder: NSCoder) {
super.init(coder: coder)
// will set color when selected to own color
selectedBackgroundView = SettingsTableViewCell.selectedBackGroundView
}
}