Skip to content

Commit

Permalink
Rename animation methods to avoid UKit conflicts
Browse files Browse the repository at this point in the history
Fixes #2
  • Loading branch information
Reda Lemeden committed Nov 10, 2014
1 parent 0e48455 commit 86a4306
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions demo/classes/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 8 additions & 4 deletions source/UIImageView+Gifu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ extension UIImageView {
}
}

var isAnimating: Bool {
return animatableImage?.isAnimating() ?? false
var isAnimatingGIF: Bool {
return animatableImage?.isAnimating() ?? isAnimating()
}

var animatable: Bool {
Expand Down Expand Up @@ -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()
}
}
}

0 comments on commit 86a4306

Please sign in to comment.