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()
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
}

View File

@ -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()
}
}
}