美文网首页
自定义系统编辑模式按钮图片

自定义系统编辑模式按钮图片

作者: Lin__Chuan | 来源:发表于2017-08-29 19:59 被阅读14次

核心思想: 分析视图结构,找到对应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"];
                    }
                }
            }
        }
    }

相关文章

网友评论

      本文标题:自定义系统编辑模式按钮图片

      本文链接:https://www.haomeiwen.com/subject/qawrrxtx.html