title: Unable to change image for the button in swift 3?
body: <p>In my code for checkmark I used button to change images for selected and unselected but unable to implement if I click on it's changing to unchecked but again selecting button it's unable to change to check image can anyone help me how to resolve this ?</p>
  
  <pre><code>var checkedImage = UIImage(named: "check")! as UIImage
  var uncheckedImage = UIImage(named: "uncheck")! as UIImage
  var isChecked: Bool = true
  var checkMarkSelected = 0
  
  checkMarkButton.addTarget(self, action: #selector(checkMarkAction(button:)), for: .touchUpInside)
  
  func checkMarkAction(button : UIButton) {
          if isChecked == true {
              checkMarkButton.setImage(checkedImage, for: .selected)
              isChecked = false
              checkMarkSelected = 1
          }
          else {
              checkMarkButton.setImage(uncheckedImage, for: .normal)
              isChecked = true
              checkMarkSelected = 0
          }
      }
  </code></pre>