Disable animation on load

This commit is contained in:
Reda Lemeden 2014-09-11 23:06:16 +02:00
parent da998e325d
commit fcaa1a9c19
2 changed files with 7 additions and 7 deletions

View File

@ -41,10 +41,9 @@ class AnimatedImage: UIImage {
super.init() super.init()
attachDisplayLink() attachDisplayLink()
prepareFrames(imageSource) prepareFrames(imageSource)
startAnimating() pauseAnimation()
} else { } else {
super.init(data: data) super.init(data: data)
stopAnimating()
} }
} }
@ -91,7 +90,6 @@ class AnimatedImage: UIImage {
if Int(index) >= self.frames.count { return nil } if Int(index) >= self.frames.count { return nil }
var image: UIImage? = self.frames[Int(index)] var image: UIImage? = self.frames[Int(index)]
updatePreloadedFramesAtIndex(index) updatePreloadedFramesAtIndex(index)
return image return image
@ -135,11 +133,11 @@ class AnimatedImage: UIImage {
} }
// MARK: - Animation // MARK: - Animation
func stopAnimating() { func pauseAnimation() {
displayLink.paused = true displayLink.paused = true
} }
func startAnimating() { func resumeAnimation() {
displayLink.paused = false displayLink.paused = false
} }

View File

@ -30,22 +30,24 @@ extension UIImageView {
// MARK: - Setter Methods // MARK: - Setter Methods
func setAnimatableImage(named name: String) { func setAnimatableImage(named name: String) {
image = AnimatedImage.imageWithName(name, delegate: self) image = AnimatedImage.imageWithName(name, delegate: self)
layer.setNeedsDisplay()
} }
func setAnimatableImage(#data: NSData) { func setAnimatableImage(#data: NSData) {
image = AnimatedImage.imageWithData(data, delegate: self) image = AnimatedImage.imageWithData(data, delegate: self)
layer.setNeedsDisplay()
} }
// MARK: - Animation // MARK: - Animation
func startAnimating() { func startAnimating() {
if animatable { if animatable {
animatableImage!.startAnimating() animatableImage!.resumeAnimation()
} }
} }
func stopAnimating() { func stopAnimating() {
if animatable { if animatable {
animatableImage!.stopAnimating() animatableImage!.pauseAnimation()
} }
} }
} }