title: UIImageView fade between animation
body: <p>I need to animate between images in a UIImageView. So after research I came out with this class:</p>
  
  <pre><code>    import UIKit
  
      class GzImageView: UIImageView {
  
      var imageCollection:[UIImage]? //images to show
      var count:Int = 0 // images counter
  
      func animate(){
          //when Counter get last image set it to the first one
          if self.count &gt;= self.imageCollection?.count {
              self.count = 0
          }
          //get the image to show
          let img = self.imageCollection![self.count]
          //animate the transition
          UIView.transitionWithView(self,
              duration: 1.0,
              options: UIViewAnimationOptions.TransitionCrossDissolve,
              animations: { self.image = img }) //set the new image
              { (Bool) -&gt; Void in
              self.animate() //Direct recursion
              self.count++
          }
      }                     
   }
  </code></pre>
  
  <p>And I use it that way:</p>
  
  <pre><code>let imgView = GzImageView(frame: CGRectMake(30, 100, 200, 200))
  imgView.imageCollection = ["cake.png","bag.png","hat.png"].map { name -&gt; UIImage in UIImage(named:name)!}
  imgView.animate()
  </code></pre>
  
  <p>It works fine when I use as an UIView subview. But I need to use this as a UICollectionViewCell subview. And as a UICollectionViewCell subview it doesn't work properly. When I change to other UIView and came back to UICollectionView images start to blink very fast.</p>
  
  <p>I couldn't figure out the problem, so I'm looking for another way to get this functionality.</p>
  
  <p>Do you guys have another way to do that or know how to fix that?</p>