jeudi 21 mai 2015

Checkbox in UICollectionViewCell swift

Hi ihave Custom Checkbox here is code

class CheckBox: UIButton {

    let checkedimage = UIImage(named: "checked")
    let uncheckimage = UIImage(named: "unchecked")

    var isCheck:Bool = false{
        didSet{
            if isCheck == true {
                self.setImage(checkedimage, forState: .Normal)
            }else{
                self.setImage(uncheckimage, forState: .Normal)
            }
        }
    }

    override func awakeFromNib() {
        self.addTarget(self, action: "ButtonClicked:", forControlEvents: UIControlEvents.TouchUpInside)
        self.isCheck = false
    }

    func ButtonClicked(sender:UIButton){
        if(sender == self) {
            if isCheck == true{
                isCheck = false
            }else{
                isCheck = true
            }
        }
    }
}

What I want to do is add Checkbox in UICollectionViewCell and when i clicked inside checkbox in cell I want to println a selected cell tag .




Aucun commentaire:

Enregistrer un commentaire