How to display activity indicator in middle of the iphone screen?

前端 未结 15 1092
盖世英雄少女心
盖世英雄少女心 2020-12-22 22:43

When we draw the image, we want to display the activity indicator. Can anyone help us?

15条回答
  •  猫巷女王i
    2020-12-22 22:55

    I found a way to display activity Indicator with minimum code:

    first of all import your UI Kit

    import UIKit;
    

    Then you have to initiate activity indicator

    let activityIndicator:UIActivityIndicatorView = UIActivityIndicatorView();
    

    Then just copy paste this functions below which are self explainatory and call them whereever you need them:

    func startLoading(){
        activityIndicator.center = self.view.center;
        activityIndicator.hidesWhenStopped = true;
        activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.gray;
        view.addSubview(activityIndicator);
    
        activityIndicator.startAnimating();
        UIApplication.shared.beginIgnoringInteractionEvents();
    
    }
    
    func stopLoading(){ 
    
        activityIndicator.stopAnimating();
        UIApplication.shared.endIgnoringInteractionEvents();
    
    }
    

提交回复
热议问题