Swift - How to stop an animation?

1

In my initial Viewcontroler I have a slide that is loading from the internet and alternating on the screen images at a time stipulated by me.

How can I stop the animation? I wanted to do this before going to another ViewController

Animation:

func animate(images: [String], index: Int = 0) {
    print(index)
    UIView.transitionWithView(imageView, duration: 10, options: .TransitionCrossDissolve, animations: {
        if let checkedUrl = NSURL(string: self.vetString[index]) {
            self.downloadImage(checkedUrl)
        }
        }, completion: { value in
            let idx = index == images.count-1 ? 0 : index+1
            self.animate(self.vetString, index: idx)
    })
}
    
asked by anonymous 09.05.2016 / 19:03

1 answer

0

I found a way. I did so:

@IBAction func paraAnimacao(sender: AnyObject) {
    var layer = imageView.layer.presentationLayer() as! CALayer
    var frame = layer.frame
    print(frame)
    imageView.layer.removeAllAnimations()
    imageView.frame = frame
}
    
09.05.2016 / 20:40