MBProgressHUD

使用:

1. loading
  • demo image.png

  • 代码

///    - loading: 以转菊花显示
///    - view: 如果传入`nil`,则显示在Window上
///    - text: 不传则不显示
showLoading(_ view:UIView?, text:String? = nil)

///    - 取消显示
dismiss(_ view:UIView?)
// 示例
MBProgressHUD.showLoading(self.view)
MBProgressHUD.dismiss(self.view)
2.吐司
  • demo image.png

  • 代码

///    - afterDelay: 默认2秒
///    - location: 默认显示在底部
///    - text: 不传则不显示
showMessage(_ text:String?, location:MBProgressHUDMessageLocation = .bottom, afterDelay:TimeInterval = 2)
// 示例
MBProgressHUD.showMessage("file")
3.显示进度和文字
  • demo image.png

  • 代码

/// 开启显示进度
///    - view: 如果传入`nil`,则显示在Window上
///    - text: 默认为 `nil`
showProgress(_ view:UIView?, text:String? = nil) 

/// 设置进度
///   - view: 如果传入`nil`,则显示在Window上
///   - progress: 进度,Float类型
///   - text: 默认为 `nil`
setShowProgress(_ view:UIView?, progress:Float, text:String? = nil)
// 示例
MBProgressHUD.showProgress(self.view, text: "update")
MBProgressHUD.setShowProgress(self.view, progress: Float(progress) / 100)
MBProgressHUD.dismiss(self.view)
4.显示成功和失败
  • demo image.png

  • 代码

///都是显示在Window上,持续2秒钟
///  - 文字为`nil`, 显示图片 
showSuccess(_ text: String? = nil)

///  - 文字为`nil`, 显示图片 
showError(_ text: String? = nil )
// 示例
MBProgressHUD.showSuccess("update")
MBProgressHUD.showError("update")

results matching ""

    No results matching ""