核心思想: 分析視圖結構,找到對應ImgView
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
//找出UITableViewCellEditControl
for (UIView *view in control.subviews)
{
if ([view isKindOfClass: [UIImageView class]]) {
//在UITableViewCellEditControl中找到imageView
UIImageView *img=(UIImageView *)view;
//這樣便可以更改按鈕的坐標
img.frame = CGRectMake(img.frame.origin.x, img.frame.origin.y, img.frame.size.width, img.frame.size.height);
//更改按鈕圖片
if (self.selected) {
img.image=[UIImage imageNamed:@"purifier_icon_pressed"];
}else
{
img.image=[UIImage imageNamed:@"purifier_icon_normal"];
}
}
}
}
}