title: Quickly updating UIView background color in Swift?
body: <p>I have an array of times for when the background color of a UIView should change colors. The array holds values from  0-10000ms, where each index is the duration between the first change and the current change. I have implemented a loop to execute the tasks at the scheduled times, and using print statements, it seems to be working. However, the background color only changes to the last color instead of changing continuously.</p>
  
  <p>I believe this is because the background color does not update until the loop is done. Is this correct, and if so, how can I fix this?</p>
  
  <pre><code>    sendingView.backgroundColor = UIColor.black
      let startingTime = getCurrentMillis()
      var found = false
      for time in receivingMsgData {
          while(!found) {
              let curDuration = getCurrentMillis() - startingTime
              if curDuration &gt; time {
                  if(sendingView.backgroundColor == UIColor.black) {
                      sendingView.backgroundColor = UIColor.white
                      print("playing at \(getCurrentMillis()-startingTime) turning white")
                  } else {
                      sendingView.backgroundColor = UIColor.black
                      print("playing at \(getCurrentMillis()-startingTime) turning black")
                  }
                  found = true
              }
          }
          found = false
      }
  </code></pre>