最近的项目是用swift写的,而一些库还是OC版,基于MBProgressHUD的稳定、简单,还有设计漂亮,所以就使用Swift仿写一个。
使用
因为是基本仿写MBProgressHUD,所以使用的方式和MBProgressHUD基本一样,当然,也加入了几个自己写的加载模式,一下是现在支持的几个模式
1.默认模式GrayIndicator(小菊花):
_ = NGProgressHUD.showHUDAdded(view, true)

2.大菊花加载模式LargeWhiteIndicator:
let hud = NGProgressHUD.showHUDAdded(view, true)
hud.mode = .LargeWhiteIndicator

3.提示语加载模式IndicatorAndText:
let hud = NGProgressHUD.showHUDAdded(view, true)
hud.animationType = .ZoomIn
hud.mode = .IndicatorAndText
hud.labelText = "Capture One"
hud.detailsLabelText = "This is a hello world expample erro date and girl for the handsome man, get out of my way.This is a hello world expample erro date and girl for the handsome man, get out of my way.This is a hello world expample erro date and girl for the handsome man, get out of my way.This is a hello world expample erro date and girl for the handsome man, get out of my way."

4.旋转环模式Rotate:
let hud = NGProgressHUD(frame: view.bounds)
view.addSubview(hud)
hud.mode = .Rotate
hud.show(true)

5.单文本提示模式
该模式下可以应用在一些需要文本提示语的场景,设置isUserInteractionEnabled可以不用和加载控件直接交互。
let hud = NGProgressHUD(frame: view.bounds)
hud.backgroundColor = UIColor.yellow.withAlphaComponent(0.1)
view.addSubview(hud)
hud.mode = .Text
hud.labelText = "章节一"
hud.detailsLabelText = "事件发生了封建势力开始的考虑是否"
hud.isUserInteractionEnabled = false
hud.show(true)

6.圆环进度模式:
设计该模式是方便以后在加载图片的场景中应用。
let hud = NGProgressHUD(frame: view.bounds)
view.addSubview(hud)
hud.mode = .Progress
hud.progress = 0.4
hud.show(true)

7.自定义视图模式:
一切为了以后便捷地扩展各种加载框。
let customView = UIView(frame: CGRect(x: 100, y: 100, width: 80, height: 80))
customView.backgroundColor = UIColor.red
let swbtn = UISwitch()
customView.addSubview(swbtn)
view.addSubview(customView)
let hud = NGProgressHUD(frame: view.bounds)
view.addSubview(hud)
hud.customView = customView
hud.mode = .CustomView
hud.show(true)
8.加载成功模式:
在一些成功或是完成的场景中使用,对于失败的场景,可以在上一个自定义模式中定义。
let hud = NGProgressHUD(frame: view.bounds)
view.addSubview(hud)
hud.mode = .SucceedStatus
hud.show(true)
hud.addSucceedAnimation("支付成功")

源代码:在目录Swift Demo/Animation项目中。