Gifu/Demo/demo/classes/ViewController.swift

40 lines
1.1 KiB
Swift
Raw Normal View History

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 {
2015-01-22 10:54:27 +00:00
@IBOutlet weak var imageView: AnimatableImageView!
2014-09-10 19:28:19 +00:00
@IBOutlet weak var button: FlatButton!
override func viewDidLoad() {
super.viewDidLoad()
2014-12-12 22:07:28 +00:00
2015-06-05 15:14:52 +00:00
imageView.animateWithImage(named: "mugen.gif")
2015-01-22 10:54:27 +00:00
2014-09-10 19:28:19 +00:00
UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false)
}
@IBAction func toggleAnimation(button: UIButton) {
if imageView.isAnimatingGIF {
imageView.stopAnimatingGIF()
2014-09-10 19:28:19 +00:00
button.layer.backgroundColor = UIColor.whiteColor().CGColor
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
} else {
imageView.startAnimatingGIF()
2014-09-10 19:28:19 +00:00
button.layer.backgroundColor = UIColor.clearColor().CGColor
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}
}
2015-06-05 15:14:52 +00:00
@IBAction func toggleGIF(sender: UISegmentedControl) {
imageView.stopAnimatingGIF()
switch sender.selectedSegmentIndex {
case 0: imageView.animateWithImage(named: "mugen.gif")
case 1: imageView.animateWithImage(named: "almost_nailed_it.gif")
default: imageView.image = .None
}
}
2014-09-10 19:28:19 +00:00
}