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() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
imageView.setAnimatableImage(named: "mugen.gif") imageView.setAnimatableImage(named: "mugen.gif")
imageView.startAnimating() imageView.startAnimatingGIF()
UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false) UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false)
} }
@IBAction func toggleAnimation(button: UIButton) { @IBAction func toggleAnimation(button: UIButton) {
if imageView.isAnimating { if imageView.isAnimatingGIF {
imageView.stopAnimating() imageView.stopAnimatingGIF()
button.layer.backgroundColor = UIColor.whiteColor().CGColor button.layer.backgroundColor = UIColor.whiteColor().CGColor
button.setTitleColor(UIColor.blackColor(), forState: .Normal) button.setTitleColor(UIColor.blackColor(), forState: .Normal)
} else { } else {
imageView.startAnimating() imageView.startAnimatingGIF()
button.layer.backgroundColor = UIColor.clearColor().CGColor button.layer.backgroundColor = UIColor.clearColor().CGColor
button.setTitleColor(UIColor.whiteColor(), forState: .Normal) button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
} }

View File

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