Swiftpack.co - spirit-jsb/Choiwan as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by spirit-jsb.
spirit-jsb/Choiwan 1.0.1
Easy to use translucent HUD framework for iOS with indicators and/or labels
⭐️ 2
🕓 6 weeks ago
iOS
.package(url: "https://github.com/spirit-jsb/Choiwan.git", from: "1.0.1")

Choiwan (彩云)

Choiwan 是一个易于使用的、带有指示器或标签的半透明 HUD。

视图结构

VMBackgroundContainerView (Background View)
        │
        └─VMBackgroundContainerView (Bezel View)
                  │ ┌───────────────┐
                  ├─┤Top Spacer View│    ┌─Activity Indicator
                  │ └───────────────┘    │
                  │                      ├─Linear Progress
                  ├──Indicator───────────┤
                  │                      ├─Doughnut Progress
                  ├──Title Label         │
                  │                      ├─Pie Progress
                  ├──Details Label       │
                  │                      ├─Text Label
                  │ ┌──────────────────┐ │
                  └─┤Bottom Spacer View│ └─Custom View
                    └──────────────────┘

基本属性及方法

属性

  • style
  • animationType
  • progress
  • progressObject
  • color
  • backgroundViewColor
  • bezelViewBlurEffectStyle
  • titleText
  • titleFont
  • titleTextColor
  • titleAttributedText
  • detailsText
  • detailsFont
  • detailsTextColor
  • detailsAttributedText
  • offset
  • margin
  • minimumSize
  • contentMargin
  • gracePeriod
  • minimumDisplayingTime*
  • removeFromSuperviewWhenStopped
  • enabledMotionEffects
  • customView
  • backgroundView
    • color
    • blurEffectStyle
  • bezelView
    • color
    • blurEffectStyle
  • titleLabel
  • detailsLabel
  • completion

方法

  • init(onView:)
  • init()
  • show(onView:animated:)
  • hide(fromView:animated:)
  • hud(fromView:)
  • show(animated:)
  • hide(animated:)
  • hide(animated:delay:)

使用方法

let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWork()
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.titleText = "Loading..."

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWork()
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.titleText = "Loading..."
hud.detailsText = "Parsing data\n(1/1)"

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWork()
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.style = .linearProgress
hud.titleText = "Loading..."

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWorkWithProgress { (progress) in
        DispatchQueue.main.async {
            hud.progress = progress
        }
    }
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.style = .doughnutProgress
hud.titleText = "Loading..."

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWorkWithProgress { (progress) in
        DispatchQueue.main.async {
            hud.progress = progress
        }
    }
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.style = .pieProgress
hud.titleText = "Loading..."

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWorkWithProgress { (progress) in
        DispatchQueue.main.async {
            hud.progress = progress
        }
    }
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.style = .linearProgress
hud.titleText = "Loading..."

let progressObject = Progress(totalUnitCount: 100)
hud.progressObject = progressObject

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWorkWithProgressObject(progressObject)
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.style = .textLabel
hud.offset = UIOffset(horizontal: 0.0, vertical: .greatestFiniteMagnitude)
hud.titleText = "Hello Choiwan!"
hud.detailsText = "Easy to use translucent HUD framework for iOS with indicators and/or labels"

hud.hide(animated: true, delay: 3.0)
let customImageView = UIImageView(image: UIImage(named: "icon_completion")?.withRenderingMode(.alwaysTemplate))

let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.style = .customView
hud.customView = customImageView
hud.titleText = "Hello Choiwan!"

hud.hide(animated: true, delay: 3.0)
let hud = VMProgressHUD.show(onView: self.view.window, animated: true)

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWork()
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.titleText = "Preparing..."
hud.minimumSize = CGSize(width: 150.0, height: 100.0)

DispatchQueue.global(qos: .userInitiated).async {
    sleep(2)
    
    DispatchQueue.main.async {
        hud.style = .doughnutProgress
        hud.titleText = "Loading..."
    }
    
    var progress: Float = 0.0
    while progress < 1.0 {
        progress += 0.01
        
        DispatchQueue.main.async {
            hud.progress = progress
        }
    
        usleep(50_000)
    }
    
    DispatchQueue.main.async {
        hud.style = .activityIndicator
        hud.titleText = "Cheaning up..."
    }
    
    sleep(2)
    
    DispatchQueue.main.async {
        let customImageView = UIImageView(image: UIImage(named: "icon_completion")?.withRenderingMode(.alwaysTemplate))
    
        hud.style = .customView
        hud.customView = customImageView
        hud.titleText = "Completed"
    }
    
    sleep(2)
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.titleText = "Preparing..."
hud.minimumSize = CGSize(width: 150.0, height: 100.0)

self._doSomeNetworkWorkWithProgress()
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.color = UIColor(red: 0.71, green: 0.12, blue: 0.87, alpha: 1.0)
hud.titleText = "Loading..."

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWork()
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}
let hud = VMProgressHUD.show(onView: self.navigationController?.view, animated: true)
hud.backgroundViewColor = UIColor(white: 0.0, alpha: 0.2)

DispatchQueue.global(qos: .userInitiated).async {
    self._doSomeWork()
    
    DispatchQueue.main.async {
        hud.hide(animated: true)
    }
}

限制条件

  • iOS 10.0+
  • Swift 5.0+

安装

Swift Package Manager

https://github.com/spirit-jsb/Choiwan.git

作者

spirit-jsb, [email protected]

许可文件

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

GitHub

link
Stars: 2
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

version 1.0.1
6 weeks ago

publish version 1.0.1

  • Optimized code
  • Fix demo displaying issues in dark mode
  • Fix unit test issues
  • CI

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics