PUWaitHUD
简介
PUWaitHUD
是几种非常好的加载动画类型,可以用来添加 API 响应等待指示器。
动画类型
类型
- 虚线
- 无穷大
- Ripley
- Quarbit
安装
Cocoapods
Cocoapods 是 Swift 和 Objective-C Cocoa 项目的依赖管理器。要使用 CocoaPods 集成 PUWaitHUD,请在 Podfile
中添加它。
pod 'PUWaitHUD'
指定版本
pod 'PUWaitHUD', :git => 'https://github.com/PayalUmraliya/PUWaitHUD.git', :branch => '1.0.4'
使用
首先,您需要在将要使用的地方的视图控制器文件中导入PUWaitHUD
。
import PUWaitHUD
显示 HUD
func showLoading(_ vwname: UIView, _ typee: ActivityIndicatorType)
{
hideLoading()
let vw = UIView.init(frame: UIScreen.main.bounds)
vw.tag = 99999
vw.backgroundColor = UIColor.black.withAlphaComponent(0.5)
let activityView = ActivityIndicators().create(type: typee)
vw.addSubview(activityView!)
activityView?.color = .clear
activityView?.center = vw.center
activityView!.startAnimating()
vwname.addSubview(vw)
}
隐藏 HUD
func hideLoading()
{
UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.viewWithTag(99999)?.removeFromSuperview()
}
注意
以上是HUD的基本用法。根据您的需要,您可以在函数中对参数进行管理,以使其全局化。
许可证
MIT 许可证 (MIT)
版权所有© 2021 Payal Umralya [[email protected]]