title: fade in fade out for an images array swift
body: <p>I have a global variable of images array</p>
  
  <pre><code>public var images = ["11", "12", "13", "14", "15", "16", "17", "18", "11", "12", "13", "14", "15", "16", "17", "18", "11", "12", "13", "14", "15", "16", "17", "18"]
  </code></pre>
  
  <p>I want to show it fade in fade out each image after 2 seconds when I click the button. Means when the image "11" appear first, after 2 seconds, it will fade out, and then the image "12" will fade in and so on. But my code doesn't work well.</p>
  
  <p>here is my code:</p>
  
  <pre><code>@IBAction func playAutomaticPhotoImages(sender: AnyObject) {
  
      for image in images {
        photoImageView.hidden = false
        photoImageView.alpha = 1.0
        UIView.animateWithDuration(2.0, animations: {
          self.photoImageView.image = UIImage(named: image)
          self.photoImageView.alpha = 1
          }, completion: {
            (value: Bool) in
            self.photoImageView.hidden = true
            self.photoImageView.alpha = 0.0
        })
      }
    }
  </code></pre>
  
  <p>here is my image:</p>
  
  <p><a href="https://i.stack.imgur.com/Jde1Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jde1Y.png" alt="enter image description here"></a></p>