Search code examples
swiftindicator

How to create Activity Indicator View?


Would you please advice me how to create an Activity Indicator View? I have a normal button:

@IBAction func NextViewController(sender: AnyObject) {


}

it takes lots of time until my app loads the next view controller and I would like to have a normal indicator which will inform the users to wait a bit.


Solution

  • I can advice you to use the LilithProgressHUD. It's the best Activity Indicator View I have ever used.

    enter image description here

    Install it with pod 'LilithProgressHUD'.

    //Import LilithProgressHUD
    import LilithProgressHUD
    
    //Show the HUD
    LilithProgressHUD.show()
    
    //Hide the HUD
    LilithProgressHUD.hide()
    

    That is literally it...

    So in your example:

    @IBAction func NextViewController(sender: AnyObject) {
    
         LilithProgressHUD.show()
    }
    

    That would be it... At the NextViewController viewDidLoad you would then call LilithProgressHUD.hide().

    Also. I have set the properties of the view within my AppDelegate.

    LilithProgressHUD.size = (self.window?.frame.size.height)! // sets the size to the size of my App
    LilithProgressHUD.opacity = 0.75 // sets the opacity nice to a value where you can slightly see the App