Thursday, July 30, 2015

UIActivityIndicatorView - Show an Activity Indicator Programmatically

Update: July 8, 2017 (Swift 3.1 + Xcode 8.3.3)
Original Post: July 30, 2015 (Swift 1 + Xcode 6.4)

Complete the code as below:

Update: July 8, 2017 (Swift 3.1 + Xcode 8.3.3)

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let myActivityIndicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.gray)
        myActivityIndicator.center = view.center
        myActivityIndicator.startAnimating()
        view.addSubview(myActivityIndicator)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

}

Original Post: July 30, 2015 (Swift 1 + Xcode 6.4)

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var myActivityIndicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.Gray)
        myActivityIndicator.center = view.center
        myActivityIndicator.startAnimating()
        view.addSubview(myActivityIndicator)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

}

The result:

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I have found that this site is very informative, interesting and very well written. keep up the nice high quality writing Sell Apple Developer Account

    ReplyDelete