when selecting a cell in tableview : set background color to blue
This commit is contained in:
parent
7437b73498
commit
48ca2795b4
|
@ -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
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue