krimpedance/KRProgressHUD


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

License: MIT

Language: Swift

Keywords: ios, progress-hud, swift


日本語

Version License Platform Download 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.

Features

  • Round indicator
  • Indicator color can be customized

Requirements

  • iOS 8.0+
  • Xcode 11.0+
  • Swift 5.1+

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 :

KRProgressHUD.show()

DispatchQueue.main.asyncAfter(deadline: .now()+1) {
   KRProgressHUD.dismiss()
}

Showing the HUD

class func show(withMessage message:String? = nil, completion: CompleteHandler? = nil)

// Example
KRProgressHUD.show()
KRProgressHUD.show(withMessage: "Loading...")
KRProgressHUD.show(withMessage: "Loading...") {
   print("Complete handler")
}

Show on ViewController

If you want to show HUD on a view controller, set at showOn().

(This is applied only once.)

  KRProgressHUD.showOn(viewController).show()

Show a confirmation glyph before getting dismissed a little bit later. (The display time is 1 sec in default. You can change the timing.)

class func showSuccess()
class func showInfo()
class func showWarning()
class func showError()
class func showImage() // This can set custom image. (Max size is 50x50)

Show the HUD (only message)

public class func showMessage(_ message: String)

// Example
KRProgressHUD.showMessage("Completed! \n Let's start!")

Update the HUD's message

The HUD can update message.

class func update(message: String)

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

Dismissing the HUD

The HUD can be dismissed using:

class func dismiss(_ completion: CompleteHandler? = nil)

Customization

KRProgressHUD.appearance() can set default styles.

class KRProgressHUDAppearance {
    /// Default style.
    public var style = KRProgressHUDStyle.white
    /// Default mask type.
    public var maskType = KRProgressHUDMaskType.black
    /// Default KRActivityIndicatorView colors
    public var activityIndicatorColors = [UIColor]([.black, .lightGray])
    /// Default message label font.
    public var font = UIFont.systemFont(ofSize: 13)
    /// Default HUD center offset of y axis.
    public var viewOffset = CGFloat(0.0)
    /// Default duration to show HUD.
    public var duration = Double(1.0)
}

When you'd like to make styles reflected only in specific situation, use following methods.

@discardableResult public class func set(style: KRProgressHUDStyle) -> KRProgressHUD.Type
@discardableResult public class func set(maskType: KRProgressHUDMaskType) -> KRProgressHUD.Type
@discardableResult public class func set(activityIndicatorViewColors colors: [UIColor]) -> KRProgressHUD.Type
@discardableResult public class func set(font: UIFont) -> KRProgressHUD.Type
@discardableResult public class func set(centerPosition point: CGPoint) -> KRProgressHUD.Type
@discardableResult public class func set(duration: Double) -> KRProgressHUD.Type


// Example
KRProgressHUD
   .set(style: .custom(background: .blue, text: .white, icon: nil))
   .set(maskType: .white)
   .show()

These set() setting can be reset by

@discardableResult public class func resetStyles() -> KRProgressHUD.Type

Contributing to this project

I'm seeking bug reports and feature requests.

Release Note

  • 3.4.4 :

    • Support SwiftPM.
  • 3.4.2 (3.4.3) :

    • Fix for iOS 13 & Xcode 11.
  • 3.4.1 :

    • Compatible with Swift 5.0.
  • 3.4.0 :

    • Updated for KRActivityIndicatorView@3.0.0.
    • Few properties and methods were renamed.

License

KRProgressHUD is available under the MIT license.

See the LICENSE file for more info.

Project Statistics

Sourcerank 9
Repository Size 25.7 MB
Stars 418
Forks 61
Watchers 12
Open issues 4
Dependencies 10
Contributors 7
Tags 37
Created
Last updated
Last pushed

Top Contributors See all

krimpedance KooFrank Jatin Arora Felix Antonio Alves Andrejs Mivreņiks Eralp Karaduman

Packages Referencing this Repo

krimpedance/KRProgressHUD
A beautiful and easy-to-use progress HUD for your iOS.
Latest release 3.4.4 - Published - 418 stars
KRProgressHUD
A beautiful progress HUD for your iOS.
Latest release 3.4.3 - Updated - 418 stars

Recent Tags See all

3.4.4 October 01, 2019
3.4.3 September 29, 2019
3.4.2 September 20, 2019
3.4.1 May 01, 2019
3.4.0 October 04, 2018
3.3.0 September 18, 2018
3.2.2 March 31, 2018
3.2.1 January 24, 2018
3.2.0 December 28, 2017
3.1.2 November 15, 2017
3.1.1 October 10, 2017
3.1.0 September 21, 2017
3.1.0-swift3.2 September 21, 2017
3.0.0 May 19, 2017
2.2.2 April 11, 2017

Interesting Forks See all

reza-khalafi/KRProgressHUD
A beautiful and easy-to-use progress HUD for your iOS.
Swift - Updated - 2 stars

Something wrong with this page? Make a suggestion

Last synced: 2019-10-01 03:38:21 UTC

Login to resync this repository