Swift对SVProgressHUD进一步封装
1,准备工作
默认已经导入SVProgressHUD
2,封装
创建一个.swift文件:MyProgressHUD
import UIKit
enum MyProgressHUDStatus {
///成功
case success
///失败
case error
///叹号提示
case info
///等待
case waitting
///只显示文字
case onlyText
///过程
case progress
}
class MyProgressHUD: NSObject {
/// 纯文字提示
static func showTipMessage(_ msg: String?) {
showWithStatus(hudStatus: .onlyText, text: msg, progress: 0)
}
/// 带!图片的提示
static func showInfoMsg(_ msg: String?) {
showWithStatus(hudStatus: .info, text: msg, progress: 0)
}
///错误 带X的图片
static func showFailure(_ msg: String?, toView: UIView?) {
showWithStatus(hudStatus: MyProgressHUDStatus.error, text: msg, progress: 0