TableViewCell点击导致subviews背景颜色消失的
//MARK: - 重写高亮和点击事件
override func setHighlighted(highlighted: Bool, animated: Bool) {
var colors: [UIView:UIColor] = [:]
for view in subviews {
colors[view] = view.backgroundColor ?? UIColor.clearColor()
}
super.setHighlighted(highlighted, animated: animated)
if highlighted {
for view in subviews {
view.backgroundColor = colors[view]
}
}
}
override func setSelected(selected: Bool, animated: Bool) {
var colors: [UIView:UIColor] = [:]
for view in subviews {
colors[view] = view.backgroundColor ?? UIColor.clearColor()
}
super.setSelected(selected, animated: animated)
if selected {
for view in subviews {
view.backgroundColor = colors[view]
}
}
}
本文标题:TableViewCell点击导致subviews背景颜色消失的
本文链接:https://www.haomeiwen.com/subject/rfamvxtx.html
网友评论