开启点击效果
- 方案1:设置cell的selectedBackgroundView属性,并设置相应的颜色值
self.selectedBackgroundView = [[UIView alloc]initWithFrame:self.bounds];
self.selectedBackgroundView.backgroundColor = kSelectTapEffectColor;
复制代码
- 方案2:取消cell选中状态样式,重写以下两个方法
self.selectionStyle = UITableViewCellSelectionStyleNone;
// 配置cell高亮状态
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
if (highlighted) {
self.contentView.backgroundColor = kSelectTapEffectColor;
} else {
// 增加延迟消失动画效果,提升用户体验
[UIView animateWithDuration:0.1