C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Action triggered: To create a "tap" event handler for the button, add an Action Triggered event. Now we add some important Swift code.
IsAnimating: This returns true if the UIActivityIndicatorView is currently animating, and false if not.
StopAnimation: Call this to pause the animation of the Activity Indicator. No motion occurs when the control is paused.
StartAnimation: Begins animating the control. Use this to get the "spinning beach ball" effect in motion.
Example UIActivityIndicatorView: Swift
//
// ViewController.swift
// ExampleTimeE
//
// ...
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var simpleActivity: UIActivityIndicatorView!
@IBOutlet weak var simpleButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func actionTriggered(sender: AnyObject) {
// See if it is animating.
if simpleActivity.isAnimating() {
// If currently animating, stop it.
simpleActivity.stopAnimating()
}
else {
// Begin.
simpleActivity.startAnimating()
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
However: When we tap (or click) the Button, the spinning beach-ball effect will begin, mesmerizing us.