2014-09-10 19:28:19 +00:00
|
|
|
import UIKit
|
2014-12-08 22:11:24 +00:00
|
|
|
import Gifu
|
2014-09-10 19:28:19 +00:00
|
|
|
|
|
|
|
class ViewController: UIViewController {
|
2016-09-26 21:01:27 +00:00
|
|
|
@IBOutlet weak var imageView: GIFImageView!
|
2016-10-01 11:19:22 +00:00
|
|
|
var currentGIFName: String = "mugen" {
|
|
|
|
didSet {
|
|
|
|
imageView.animate(withGIFNamed: currentGIFName)
|
|
|
|
}
|
2014-09-10 19:28:19 +00:00
|
|
|
}
|
|
|
|
|
2016-06-18 22:56:52 +00:00
|
|
|
@IBAction func toggleAnimation(_ sender: AnyObject) {
|
2014-11-10 21:57:37 +00:00
|
|
|
if imageView.isAnimatingGIF {
|
|
|
|
imageView.stopAnimatingGIF()
|
2014-09-10 19:28:19 +00:00
|
|
|
} else {
|
2014-11-10 21:57:37 +00:00
|
|
|
imageView.startAnimatingGIF()
|
2015-06-05 15:14:52 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-01 11:19:22 +00:00
|
|
|
|
|
|
|
@IBAction func swapImage(_ sender: AnyObject) {
|
|
|
|
switch currentGIFName {
|
|
|
|
case "mugen":
|
|
|
|
currentGIFName = "earth"
|
|
|
|
default:
|
|
|
|
currentGIFName = "mugen"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
|
|
imageView.prepareForReuse()
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
|
|
imageView.animate(withGIFNamed: currentGIFName)
|
|
|
|
}
|
|
|
|
|
|
|
|
@IBAction func unwindToRootViewController(segue: UIStoryboardSegue) { }
|
2014-09-10 19:28:19 +00:00
|
|
|
}
|