title: In Swift 3 - I am trying to change the color of a button for a second after clicking it, so the user will get an indication if was right or wrong
body: <p>In Swift 3 - I am trying to change the color of the button for a second after clicking it, so the user will get an indication if was right or wrong. It seems like I need to force update the display, but I am not sure how.</p>
  
  <pre><code>@IBAction func answer1(_ sender: UIButton) {
      if (sender.tag == rightAnswerPlacement) {
          sender.backgroundColor = UIColor.green
          gmaeScore += 1
      } else {
          sender.backgroundColor = UIColor.red
          gmaeScore -= 1
      }
      sleep(1)
      score.text = "Score: \(gmaeScore)"
      newQuestion()
  }
  
  func newQuestion() {
      var firstResult: Int, secondResult: Int, thirdResult: Int, finalResult:Int
      (firstResult, secondResult, thirdResult, finalResult) = generateQuestion()
  
      timeCount = 0
  
      firstAnswer.text = String(firstResult)
      secondAnswer.text = String(secondResult)
      thirdAnswer.text = String(thirdResult)
  
      rightAnswerPlacement = generateNumber(range: 4, positive: true)
  
      var button:UIButton = UIButton()
  
      var alternativeAnswer = 0
  
      //IUterate over the buttons
  
      var allAnswers = Set&lt;Int&gt;()
      allAnswers.insert(finalResult)
  
      for i in 1...4 {
          //Converting each of the buuton tags into a button
          button = view.viewWithTag(i) as! UIButton
          button.backgroundColor = UIColor.blue
          if (i == Int(rightAnswerPlacement)){
              button.setTitle(String(finalResult), for: .normal)
          } else {
              var myRange = finalResult * 2
              if (myRange &lt; 0) {
                  myRange *= -1
              }
              alternativeAnswer =  generateNumber(range: myRange)
              while allAnswers.contains(alternativeAnswer) {
                  alternativeAnswer =  generateNumber(range: myRange)
              }
              allAnswers.insert(alternativeAnswer)
              button.setTitle(String(alternativeAnswer), for: .normal)
          }
      }
  </code></pre>