Gifu/demo/classes/ViewController.swift

28 lines
849 B
Swift
Raw Normal View History

2014-09-10 19:28:19 +00:00
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var button: FlatButton!
override func viewDidLoad() {
super.viewDidLoad()
imageView.setAnimatableImage(named: "mugen.gif")
imageView.startAnimating()
UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: false)
}
@IBAction func toggleAnimation(button: UIButton) {
if imageView.isAnimating {
imageView.stopAnimating()
button.layer.backgroundColor = UIColor.whiteColor().CGColor
button.setTitleColor(UIColor.blackColor(), forState: .Normal)
} else {
imageView.startAnimating()
button.layer.backgroundColor = UIColor.clearColor().CGColor
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}
}
}