How to handle CheckBox event in Swift

A very simple checkbox control.

 @IBAction func btn_box(sender: UIButton) {
        if (btn_box.selected == true)
        {
            btn_box.setBackgroundImage(UIImage(named: "box"), forState: UIControlState.Normal)
            
                btn_box.selected = false;
        }
        else
        {
            btn_box.setBackgroundImage(UIImage(named: "checkBox"), forState: UIControlState.Normal)
            
            btn_box.selected = true;
        }
    }


0 nhận xét:

Đăng nhận xét