DLProgressHUD 2.0.0

DLProgressHUD 2.0.0

Alonso 维护。



  • DeluxeAlonso

DLProgressHUD

CI Status Version License Platform

轻量级的 iOS Progress HUD 实现。

示例

加载 显示文本的加载 仅文本 图像 图像和文本

示例项目

要运行示例项目,请克隆仓库,并在 Example 目录中先运行 `pod install`。

要求

DLProgressHUD 需要 iOS 14.0 和 Swift 5.0 或更高版本。

安装

DLProgressHUD可以通过CocoaPods获取。为了安装它,只需将以下行添加到您的Podfile中

pod 'DLProgressHUD'

用法

可以使用多种模式来显示进度HUD:加载、加载With文本、仅文本、图片和图片With文本。

只需调用show方法,并传入HUD模式作为参数即可

DLProgressHUD.show(.loading)

可用的HUD模式

模式 描述
loading 仅带活动指示器的HUD
loadingWithText(_ text: String) 带活动指示器和文本标签的HUD
textOnly(_ text: String) 仅带文本标签的HUD
image(_ image: UIImage) 仅带图片视图的HUD
imageWithText(image: UIImage, text: String) 带图片视图和文本标签的HUD

外观和呈现配置

有两种方式可以配置DLProgressHUD的外观和呈现

  1. 您可以在实例化之前使用DefaultHudConfiguration类进行全局配置。
DLProgressHUD.defaultConfiguration.backgroundInteractionEnabled = true
DLProgressHUD.show(.loading)
  1. 您可以创建自己的配置实例,该实例符合HudConfigurationProtocol协议,并将其传递给DLProgressHUD的方法。
struct HudCustomConfiguration: HudConfigurationProtocol {
    var hudContentPreferredHeight: CGFloat = 64
    var hudContentPreferredWidth: CGFloat = 180
    var textFont: UIFont = .systemFont(ofSize: 18.0)
}
let configuration = HudCustomConfiguration()
DLProgressHUD.show(.textOnly("Loading..."), configuration: configuration)

作者

DeluxeAlonso, [email protected]

许可证

DLProgressHUD 适用于 MIT 许可证。更多信息请参阅 LICENSE 文件。