Rename animation methods to avoid UKit conflicts

Fixes #2
This commit is contained in:
Reda Lemeden 2014-11-10 22:57:37 +01:00
parent 0e48455fe3
commit 86a43066f4
2 changed files with 12 additions and 8 deletions

View File

@ -8,17 +8,17 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
imageView.setAnimatableImage(named: "mugen.gif")
imageView.startAnimating()
imageView.startAnimatingGIF()
UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false)
}
@IBAction func toggleAnimation(button: UIButton) {
if imageView.isAnimating {
imageView.stopAnimating()
if imageView.isAnimatingGIF {
imageView.stopAnimatingGIF()
button.layer.backgroundColor = UIColor.whiteColor().CGColor
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
} else {
imageView.startAnimating()
imageView.startAnimatingGIF()
button.layer.backgroundColor = UIColor.clearColor().CGColor
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}

View File

@ -10,8 +10,8 @@ extension UIImageView {
}
}
var isAnimating: Bool {
return animatableImage?.isAnimating() ?? false
var isAnimatingGIF: Bool {
return animatableImage?.isAnimating() ?? isAnimating()
}
var animatable: Bool {
@ -39,15 +39,19 @@ extension UIImageView {
}
// MARK: - Animation
func startAnimating() {
func startAnimatingGIF() {
if animatable {
animatableImage!.resumeAnimation()
} else {
startAnimating()
}
}
func stopAnimating() {
func stopAnimatingGIF() {
if animatable {
animatableImage!.pauseAnimation()
} else {
stopAnimating()
}
}
}