diff --git a/source/Gifu.swift b/source/Gifu.swift index 8373c5c..f396817 100644 --- a/source/Gifu.swift +++ b/source/Gifu.swift @@ -41,10 +41,9 @@ class AnimatedImage: UIImage { super.init() attachDisplayLink() prepareFrames(imageSource) - startAnimating() + pauseAnimation() } else { super.init(data: data) - stopAnimating() } } @@ -91,7 +90,6 @@ class AnimatedImage: UIImage { if Int(index) >= self.frames.count { return nil } var image: UIImage? = self.frames[Int(index)] - updatePreloadedFramesAtIndex(index) return image @@ -135,11 +133,11 @@ class AnimatedImage: UIImage { } // MARK: - Animation - func stopAnimating() { + func pauseAnimation() { displayLink.paused = true } - func startAnimating() { + func resumeAnimation() { displayLink.paused = false } diff --git a/source/UIImageView+Gifu.swift b/source/UIImageView+Gifu.swift index 8146c56..49597de 100644 --- a/source/UIImageView+Gifu.swift +++ b/source/UIImageView+Gifu.swift @@ -30,22 +30,24 @@ extension UIImageView { // MARK: - Setter Methods func setAnimatableImage(named name: String) { image = AnimatedImage.imageWithName(name, delegate: self) + layer.setNeedsDisplay() } func setAnimatableImage(#data: NSData) { image = AnimatedImage.imageWithData(data, delegate: self) + layer.setNeedsDisplay() } // MARK: - Animation func startAnimating() { if animatable { - animatableImage!.startAnimating() + animatableImage!.resumeAnimation() } } func stopAnimating() { if animatable { - animatableImage!.stopAnimating() + animatableImage!.pauseAnimation() } } }