当改变了tableViewCell的宽度,他的点击效果的宽度并没有变化
可以自己写一个模拟动画
1首先关闭点击效果
self.selectionStyle=UITableViewCellSelectionStyleNone;
2.重写setSelected,setHighlighted这两个方法
// 配置cell选中状态
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
[self setSelectedOrHighlighted:selected animated:animated];
}
// 配置cell高亮状态
-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
[super setHighlighted:highlighted animated:animated];
[self setSelectedOrHighlighted:highlighted animated:animated];
}
-(void)setSelectedOrHighlighted:(BOOL)on animated:(BOOL)animated{
if (animated) {
[UIView animateWithDuration:0.4 animations:^{
[self setSelectedOrHighlighted:on];
}];
}
else{
[self setSelectedOrHighlighted:on];
}
}
-(void)setSelectedOrHighlighted:(BOOL)on{
self.colorView.alpha=0.5*on;
}