LPProgressHUD
LPProgressHUD 是一个 Swift 版本的 HUD,模仿 MBProgressHUD.
要求
- iOS 9.0+
- Xcode 11.3.1+
- Swift 5.0+
安装
CocoaPods
CocoaPods 是一个用于 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 LPProgressHUD 集成到您的 Xcode 项目中,请在您的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'LPProgressHUD', '~> 1.0.1’
end
然后,运行以下命令
$ pod install
Carthage
Carthage是一个去中心化的依赖管理器,它构建您的依赖关系并提供二进制框架。
您可以使用以下命令使用Homebrew安装Carthage:
$ brew update
$ brew install carthage
要使用Carthage将LPProgressHUD集成到您的Xcode项目中,请在您的Cartfile
中指定它。
github "leo-lp/LPProgressHUD"
运行carthage update
来构建框架,并将构建的LPProgressHUD.framework
拖到您的Xcode项目中。
手动
如果您不想使用上述任一依赖管理器,您可以手动将LPProgressHUD集成到项目中。
使用方法
使用MBProgressHUD在主线程上设置,然后切换要执行的任务到新线程。
let hud = LPProgressHUD.show(to: view, animated: true)
DispatchQueue.global().async {
// Do something...
DispatchQueue.main.sync {
hud.hide(animated: true)
}
}
有关更多示例,包括如何使用LPProgressHUD与异步操作一起使用的信息,请查看附带示例项目。
许可证
代码根据MIT许可证的条款和条件分发。