Is it possible to achieve this using swift
?
I would like to make many checkboxes inside an UIView
in swift
Simple just check for the image loaded on button and take appropriate action see below code:
// declare bool
var unchecked = true
@IBAction func tick(sender: UIButton) {
if unchecked {
sender.setImage(UIImage(named:"checked.png"), forControlState: .Normal)
unchecked = false
}
else {
sender.setImage( UIImage(named:"unchecked.png"), forControlState: .Normal)
unchecked = true
}
}
Note:
checked
and unchecked
.