项目里用到UITableview的编辑效果,需要更改左边选择的图片(如下图),我又是个忠于原生控件(懒得自定义)的人,系统没有给改变的api,所以又用了偷梁换柱啊
以下是我在cell里面打印的cell.subviews, UITableViewCellEditControl就是左边的图片,取到里面的UIimageView更改图片就可以了
下面贴代码:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; if (self.isEditing && self.isSelected) { UIControl *control = [self.subviews lastObject]; UIImageView * imgView = [[control subviews] objectAtIndex:0]; imgView.image = [UIImage imageNamed:@"选中icon1"]; } // Configure the view for the selected state }
原文:http://www.cnblogs.com/lilufeng/p/5056147.html