Disable animation on load
This commit is contained in:
parent
da998e325d
commit
fcaa1a9c19
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue