I am going to work on a project that will use a lot of checkboxes. I found a solution like below, but I know this not right way.
@IBAction func btn_box(sender:
There are lots of Checkbox control or you do it by this simple way:
For Storyboard:
Set your button's selected image:
Set your button's default image:
For Programmatically:
btn_box.setBackgroundImage(UIImage(named: "box"), for: .normal)
btn_box.setBackgroundImage(UIImage(named: "checkBox"), for: .selected)
And in button action:
@IBAction func btn_box(sender: UIButton) {
sender.isSelected = !sender.isSelected
}