KRProgressHUD travis-ci CocoaPods

A beautiful and easy-to-use progress HUD for your iOS.

3 years after

日本語

KRProgressHUD

Version License Platform Carthage compatible CI Status

KRProgressHUD is a beautiful and easy-to-use progress HUD for your iOS written by Swift.

KRActivityIndicatorView is used for loading view.

Requirements

ver. 2.* (current version)

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 3.*

ver. 1.*(1.7.0 and over)

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 2.3.*

ver. 1.*(under 1.7.0)

  • iOS 8.0+
  • Xcode 7.*
  • Swift 2.2.*

DEMO

To run the example project, clone the repo, and open KRProgressHUDDemo.xcodeproj from the DEMO directory.

or appetize.io

Installation

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"

Usage

(see sample Xcode project in /Demo)

Caution :

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()
}

Showing the HUD

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...")
...

Update the HUD's message

The HUD can update message.

class func update(text: String)

// Example
KRProgressHUD.update(text: "20%")

Dismissing the HUD

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()

Customization

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.

Contributing to this project

I'm seeking bug reports and feature requests. (And please teach me if my English is wrong :| )

Release Note

  • 2.0.0 : Corresponding to Swift3.

License

KRProgressHUD is available under the MIT license. See the LICENSE file for more info.

Related Repositories

awesome-swift

awesome-swift

A collaborative list of awesome swift resources. Feel free to contribute! ...

ios-dev

ios-dev

ios开发用到的插件或教程等 ...

awesome-swift

awesome-swift

A collaborative list of awesome swift resources. Feel free to contribute! ...

awesome-swift

awesome-swift

A collaborative list of awesome swift resources. Feel free to contribute! ...

awesome-swift

awesome-swift

A collaborative list of awesome swift resources. Feel free to contribute! ...


Top Contributors

krimpedance nschucky eralpkaraduman

Releases

-   2.1.0 zip tar
-   2.0.0 zip tar
-   2.0.0-beta.1 zip tar
-   1.8.0 zip tar
-   1.7.0 zip tar
-   1.6.2 zip tar
-   1.6.1 zip tar
-   1.6.0 zip tar
-   1.5.2 zip tar
-   1.5.1 zip tar
-   1.5.0 zip tar
-   1.4.3 zip tar
-   1.4.2 zip tar
-   1.4.1 zip tar
-   1.4.0 zip tar
-   1.3.0 zip tar
-   1.2.1 zip tar
-   1.2.0 zip tar
-   1.1.0 zip tar
-   1.0.0 zip tar