title: How to make an animation repeat a certain amount of times?
body: <p>For some reason when I click on the button it just does nothing and the whole app shuts down. Does anyone have any suggestions? They would be much appreciated.</p>
  
  <pre><code>var start = 1
  var timer = Timer()
  
  func test() {
      start += 1
  }
  
  @IBAction func start(_ sender: Any) {
      timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(TestViewController.test), userInfo: nil, repeats: true)
  
      while start &lt;= 10 {
          UIView.animate(withDuration: 0.1, delay: 0, options: [.repeat, .autoreverse], animations: {
              self.buttonLabel.center = CGPoint(x:self.buttonLabel.center.x + 10, y:self.buttonLabel.center.y)
      }, completion: nil)
      }
  }
  </code></pre>