How to use MBProgressHUD with swift

后端 未结 10 1765
北海茫月
北海茫月 2020-12-08 02:23

here is my code , but it showing the progress . is there any error in this code? please give some idea to fix this, or give some link related to this.

class          


        
10条回答
  •  忘掉有多难
    2020-12-08 02:40

    Create Extension to Easy to use and throughout application

    extension UIViewController {
    
        func showHUD(progressLabel:String){
            DispatchQueue.main.async{
                let progressHUD = MBProgressHUD.showAdded(to: self.view, animated: true)
                progressHUD.label.text = progressLabel
            }
        }
    
        func dismissHUD(isAnimated:Bool) {
            DispatchQueue.main.async{
                MBProgressHUD.hide(for: self.view, animated: isAnimated)
            }
        }
    }
    

    USAGE:

    1. SHOW - self.showHUD(progressLabel: "Loading...")

    2. HIDE - self.dismissHUD(isAnimated: true)

提交回复
热议问题