Latest 1.2.0
Homepage https://github.com/spirit-jsb/JSHUD
License MIT
Platforms ios 9.0, requires ARC
Frameworks UIKit, Foundation, QuartzCore, CoreGraphics
Authors

JSHUD
JSHUD
JSHUD
JSHUD
JSHUD

JSHUD All Style

示例代码

如需要运行示例项目,请 clone 当前 repo 到本地,并且从根目录下执行 JSHUD.xcworkspace,打开项目后切换 SchemeJSHUD-Demo 即可。

JSHUD 使用方法

Loading Example

JSHUD Loading

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
DispatchQueue.global().async {
    self.doSomeWork()
    DispatchQueue.main.async {
    hud.hideAnimated(true)
    }
}

Loading With label Example

JSHUD Loading With Label

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.label.text = "Loading..."
DispatchQueue.global().async {
    self.doSomeWork()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

Loading With details label Example

JSHUD Loading With Details Label

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.label.text = "Loading..."
hud.detailsLabel.text = "Parsing datan(1/1)"
DispatchQueue.global().async {
    self.doSomeWork()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

Bar progress Example

JSHUD Bar Progress

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.mode = .barProgress
hud.label.text = "Loading..."
DispatchQueue.global().async {
    self.doSomeWorkWithProgress()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

Ring progress Example

JSHUD Ring Progress

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.mode = .ringProgress
hud.label.text = "Loading..."
hud.detailsLabel.text = "Parsing datan(1/1)"
DispatchQueue.global().async {
    self.doSomeWorkWithProgress()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

Sector progress Example

JSHUD Sector Progress

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.mode = .sectorProgress
hud.label.text = "Loading..."
DispatchQueue.global().async {
    self.doSomeWorkWithProgress()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

Text Example

JSHUD Text

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.mode = .text
hud.label.text = "Message here!"

hud.offset = CGPoint(x: 0.0, y: JSHUD.JSProgressMaxOffset)

hud.hideAnimated(true, afterDelay: 3.0)

Custom Example

JSHUD Custom

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.mode = .custom
hud.label.text = "Success here!"

let image = UIImage(named: "icon_check")?.withRenderingMode(.alwaysTemplate)
hud.customView = UIImageView(image: image)

hud.hideAnimated(true, afterDelay: 3.0)

Solid Background Color Example

JSHUD Solid Background

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)

hud.backgroundView.backgroundStyle = .solidColor
hud.backgroundView.color = UIColor.red.withAlphaComponent(0.1)

DispatchQueue.global().async {
    self.doSomeWork()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

Content Color Example

JSHUD Content Color

let hud = JSHUD.showHUD(addTo: self.navigationController!.view, animated: true)
hud.contentColor = UIColor(red: 0.0, green: 0.6, blue: 0.7, alpha: 1.0)

hud.label.text = "Loading..."

DispatchQueue.global().async {
    self.doSomeWork()
    DispatchQueue.main.async {
        hud.hideAnimated(true)
    }
}

此外还有 HUD 的组合操作,具体代码请参考 JSHUD-Demo 中的示例。

注意事项

⚠️ 请确保 JSHUD 是在主线程执行的,否则会抛出异常信息! ⚠️

Swift 版本依赖

Swift JSHUD
4.0 1.0.0~1.0.1
4.2 >= 1.1.0
5.0 >= 1.2.0

限制条件

  • iOS 9.0 and Up
  • Xcode 10.0 and Up
  • Swift Version = 5.0

安装

JSHUD 可以通过 CocoaPods 获得。安装只需要在你项目的 Podfile 中添加如下字段:

pod 'JSHUD', '~> 1.2.0'

作者

spirit-jsb, [email protected]

许可文件

JSHUD 可在 MIT 许可下使用,更多详情请参阅许可文件。

Latest podspec

{
    "name": "JSHUD",
    "version": "1.2.0",
    "summary": "u4e00u4e2au7b80u4fbfu6613u7528u7684u81eau5b9au4e49 Progress HUD u6846u67b6u3002",
    "description": "u4e00u4e2au7b80u4fbfu6613u7528u7684u81eau5b9au4e49 Progress HUD u6846u67b6uff0cu65b9u4fbfu5febu6377u7684u5b9au5236 HUDu3002",
    "homepage": "https://github.com/spirit-jsb/JSHUD",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "spirit-jsb": "[email protected]"
    },
    "swift_versions": "5.0",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/spirit-jsb/JSHUD.git",
        "tag": "1.2.0"
    },
    "source_files": "Sources/**/*.swift",
    "requires_arc": true,
    "frameworks": [
        "UIKit",
        "Foundation",
        "QuartzCore",
        "CoreGraphics"
    ]
}

Pin It on Pinterest

Share This