iOS开发cell自定义高亮和选中背景颜色

//重写高亮
override func setHighlighted(highlighted: Bool, animated: Bool) {
// super.setHighlighted(highlighted, animated: animated)
if highlighted {
self.backgroundColor = UIColor(white: 0, alpha: 0.45)
}else {
self.backgroundColor = UIColor(white: 0, alpha: 0.25)
}
}
//重写选中
override func setSelected(selected: Bool, animated: Bool) {
// super.setSelected(selected, animated: animated)
if selected {
self.backgroundColor = UIColor(white: 0, alpha: 0.45)
}else {
self.backgroundColor = UIColor(white: 0, alpha: 0.25)
}
}

你可能感兴趣的:(iOS开发cell自定义高亮和选中背景颜色)