Swift4.0 替换cell编辑模式下的选中图标和未选中图标

在自定义的cell里重写layoutSubviews()方法,然后遍历替换

override func layoutSubviews() {
        super.layoutSubviews()
        for control in self.subviews{
            if control.isMember(of: NSClassFromString("UITableViewCellEditControl")!) {
                for v in control.subviews{
                    if(v.isKind(of: UIImageView.self)){
                        let img = v as! UIImageView
                        if(self.isSelected){
                            img.image = UIImage(named: "btn_choice_s")
                        }else{
                            img.image = UIImage(named: "btn_choice_n")
                        }
                    }
                }
            }
            
        }
    }
    

你可能感兴趣的:(iOS,Swift)