KRProgressHUD
is a beautiful and easy-to-use progress HUD for your iOS written by Swift.
KRActivityIndicatorView is used for loading view.
- iOS 9.0+
- Xcode 8.0+
- Swift 3.*
- iOS 8.0+
- Xcode 8.0+
- Swift 2.3.*
- iOS 8.0+
- Xcode 7.*
- Swift 2.2.*
To run the example project, clone the repo, and open KRProgressHUDDemo.xcodeproj
from the DEMO directory.
or appetize.io
KRProgressHUD is available through CocoaPods and Carthage. To install it, simply add the following line to your Podfile or Cartfile:
# CocoaPods
pod "KRProgressHUD"
# Carthage
github "Krimpedance/KRProgressHUD"
(see sample Xcode project in /Demo)
Only use it if you absolutely need to perform a task before taking the user forward.
If you want to use it with other cases (ex. pull to refresh), I suggest using KRActivityIndicatorView.
KRProgressHUD
is created as a singleton.
At first, import KRProgressHUD
in your swift file.
Show simple HUD (using GCD) :
KRProgressHUD.show()
let delay = DispatchTime.now() + 1
DispatchQueue.main.asyncAfter(deadline: delay) {
KRProgressHUD.dismiss()
}
You can show HUD with some args. You can appoint only the args which You want to appoint. (Args is reflected only this time.)
// progressHUDStyle : background color of progressView
// maskType : background color of maskView
// activityIndicatorStyle : style of KRActivityIndicatorView
// message : Text to display together
// image : Image that display instead of activity indicator
class func show(
progressHUDStyle progressStyle :KRProgressHUDStyle? = nil,
maskType type:KRProgressHUDMaskType? = nil,
activityIndicatorStyle indicatorStyle :KRProgressHUDActivityIndicatorStyle? = nil,
message :String? = nil,
font :UIFont? = nil,
image :UIImage? = nil,
completion: (()->())? = nil
)
// Example
KRProgressHUD.show()
KRProgressHUD.show(message: "Loading...")
KRProgressHUD.show(progressHUDStyle: .black, message: "Loading...")
...
The HUD can update message.
class func update(text: String)
// Example
KRProgressHUD.update(text: "20%")
The HUD can be dismissed using:
class func dismiss(_ completion: (()->())?)
Show a confirmation glyph before getting dismissed a little bit later. (The display time is 1 sec.)
These can appoint some args like show()
, too.
class func showSuccess()
class func showInfo()
class func showWarning()
class func showError()
KRProgressHUD
can be customized via the following methods.
public class func set(maskType: KRProgressHUDMaskType) // Default is .black
public class func set(style: KRProgressHUDStyle) // Default is .white
public class func set(activityIndicatorStyle: KRProgressHUDActivityIndicatorStyle) // Default is .black
public class func set(font: UIFont) // Default is Hiragino Sans W3 13px (When it can't be used, system font 13px)
public class func set(centerPosition: CGPoint) // Default is center of device screen.
KRActivityIndicatorView
's style, please refer to here.
I'm seeking bug reports and feature requests. (And please teach me if my English is wrong :| )
- 2.0.0 : Corresponding to Swift3.
KRProgressHUD is available under the MIT license. See the LICENSE file for more info.