Alberto Mier Alberto Mier - 1 year ago 225
Swift Question

Make CheckBox in swift

Is it possible to achieve this using


enter image description here

I would like to make many checkboxes inside an

Answer Source

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


  • You need to use two different images named as checked and unchecked.
  • Then above code is used for separate button (checkmarks) you need to create.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download